package com.v1.video.engine;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.iss.httpclient.NormalHttpClient;
import com.iss.httpclient.core.BasicRequestHandler;
import com.iss.httpclient.core.HttpRequestException;
import com.iss.httpclient.core.HttpResponse;
import com.iss.httpclient.core.ParameterList;
import com.iss.httpclient.core.ParameterList.FileParameter;
import com.iss.httpclient.core.ParameterList.StringParameter;
import com.iss.httpclient.core.RequestHandler;
import com.v1.video.Constant;
import com.v1.video.domain.ActionInfoConfig;
import com.v1.video.domain.AddAlbumForVideoPageInfo;
import com.v1.video.domain.BaseInfo;
import com.v1.video.domain.BindInfo;
import com.v1.video.domain.CarouselEntity;
import com.v1.video.domain.Category;
import com.v1.video.domain.ChooseAlbumPageInfo;
import com.v1.video.domain.ClassificationInfoConfig;
import com.v1.video.domain.CommentEntity;
import com.v1.video.domain.CommentListCountInfo;
import com.v1.video.domain.CommentListInfo;
import com.v1.video.domain.CommonPageInfo;
import com.v1.video.domain.FriendUpdataPageInfo;
import com.v1.video.domain.GetFriendBySharePageInfo;
import com.v1.video.domain.GetUserFriendPageInfo;
import com.v1.video.domain.Group;
import com.v1.video.domain.GroupAuditPageInfo;
import com.v1.video.domain.GroupHomePageHeadInfoConfig;
import com.v1.video.domain.GroupMembersInfoConfig;
import com.v1.video.domain.GroupRedPointInfoConfig;
import com.v1.video.domain.GroupSetupInfoConfig;
import com.v1.video.domain.Header;
import com.v1.video.domain.IsEditUserNameInfo;
import com.v1.video.domain.IsqueryUserphoneInfo;
import com.v1.video.domain.IsuserInfo;
import com.v1.video.domain.LoadingPageInfo;
import com.v1.video.domain.LoginInfo;
import com.v1.video.domain.MessageRedPointPageInfo;
import com.v1.video.domain.MessageSwitchPageInfo;
import com.v1.video.domain.MyCenterInfo;
import com.v1.video.domain.MyQuanziListInfoConfig;
import com.v1.video.domain.MyShouYiPageInfo;
import com.v1.video.domain.MyV1FocusOnorFansInfo;
import com.v1.video.domain.PaikeVideoDetailPageInfo3;
import com.v1.video.domain.PayOrderConfig;
import com.v1.video.domain.PayOrderEntity;
import com.v1.video.domain.PersonCenterVideoPageInfo;
import com.v1.video.domain.RegistPageInfo;
import com.v1.video.domain.ResultInfo;
import com.v1.video.domain.ResultInfo2;
import com.v1.video.domain.ResultObjectInfo;
import com.v1.video.domain.RewardVideoConfig;
import com.v1.video.domain.TickEntity;
import com.v1.video.domain.TopicListInfoConfig;
import com.v1.video.domain.TopicTitleInfoConfig;
import com.v1.video.domain.UpdateHeadImgPageInfo;
import com.v1.video.domain.UploadJingciPageInfo;
import com.v1.video.domain.UserAlbumPageInfo;
import com.v1.video.domain.UserAlbumVideoInfoConfig;
import com.v1.video.domain.VPaikeCommentInfo;
import com.v1.video.domain.VPaikeCommentListInfo;
import com.v1.video.domain.VPaikeRecommendInfo;
import com.v1.video.domain.VPaikeRecommendListInfo;
import com.v1.video.domain.VersionCheckPageInfo;
import com.v1.video.domain.VideoCategorieConfig;
import com.v1.video.domain.VideoCollectionInfo;
import com.v1.video.domain.VideoDetailInfo;
import com.v1.video.domain.VideoDetailOfFocousPageInfo;
import com.v1.video.domain.VideoDetailsPaikeVideoListInfo;
import com.v1.video.domain.VideoFileEntity;
import com.v1.video.domain.VideoForPaikeInfo;
import com.v1.video.domain.VideoInfo;
import com.v1.video.domain.VideoReportInfo;
import com.v1.video.domain.VideoStateOfUploadPageInfo;
import com.v1.video.domain.VideoToZhuanmaPageInfo;
import com.v1.video.domain.VoteResults;
import com.v1.video.domain.WaterFallDataInfoConfig;
import com.v1.video.domain.WeiXinPageInfo;
import com.v1.video.exception.NetException;
import com.v1.video.exception.ServicesException;
import com.v1.video.httpApi.V1VideoHttpApi;
import com.v1.video.httpmanager.ParamList;
import com.v1.video.httpmanager.ParamList.Parameter;
import com.v1.video.httpmanager.RequestManager;
import com.v1.video.httpmanager.RequestManager.OnResponseListener;
import com.v1.video.util.Logger;
import com.v1.video.util.ParamSignUtil;
import com.v1.video.util.Utils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class NetEngine {
	public final String TAG = "NetEngine";

	/**
	 * 保存修改的频道列表
	 * 
	 * @param userId
	 * @param cid
	 *            频道id字符串，逗号分割。例如：“cid1,cid2”
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addUserMsChannelList(String userId, String cid)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("cid", cid));
		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_USER_MS_CHANNEL_LIST, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo info = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(info.getResult()
						.getCode())) {
					return true;
				} else {
					throw new ServicesException(info.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 获取视频“赞”的数量 <br/>
	 * 通过url请求v1
	 * 
	 * @param newsId
	 * @return
	 * @throws ServicesException
	 */
	public VoteResults findSelfVoteResults(String newsId)
			throws ServicesException {
		String json = null;
		try {
			json = getJsonByGet(Constant.FIND_SELF_VOTE_RESULT + newsId, null);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				json = fromatJson(json);
				return gson.fromJson(json, VoteResults.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 点“赞”提交 (v1)
	 * 
	 * @param newsId
	 * @return
	 * @throws ServicesException
	 */
	public boolean voteSubmit(String newsId) throws ServicesException {
		String json = null;
		try {
			json = getJsonByGet(Constant.SUBMIT_SELF_VOTE_RESULT + newsId, null);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			throw new ServicesException("服务器返回数据错误");
		} else {
			try {
				json = fromatJson(json);
				JSONObject jsonObject = new JSONObject(json);
				return jsonObject.optBoolean(Constant.RESULT);
			} catch (JSONException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	private String fromatJson(String s) {
		return s.substring(s.indexOf('(') + 1, s.indexOf(')'));
	}

	/**
	 * 获取评论条数 (v1)
	 * 
	 * @param newsId
	 *            新闻ID 1061788
	 * @param newsLink
	 *            播放页url http://www.v1.cn/2014-04-02/1061788.shtml
	 * @return
	 * @throws ServicesException
	 */
	public CommentListCountInfo queryCommentListCount(String newsId,
			String newsLink) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("newsId", newsId));
		params.add(new StringParameter("newsLink", newsLink));
		String json = null;
		try {
			json = getJsonByGet(Constant.QUERY_COMMENT_LIST_COUNT, params);
		} catch (NetException e) {
			e.printStackTrace();
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				if (json.contains("errorMes")) {
					JSONObject jsonObject = new JSONObject(json);
					throw new ServicesException(
							jsonObject.getString("errorMes"));
				} else {
					return gson.fromJson(json, CommentListCountInfo.class);
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException("服务器返回数据错误");
			} catch (JSONException e1) {
				e1.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 获取评论列表(v1)
	 * 
	 * @param newsId
	 *            新闻ID
	 * @param newsLink
	 *            新闻播放页url
	 * @param curPage
	 *            第几页(默认值1)--每页默认8条评论休息
	 * @return
	 * @throws ServicesException
	 */
	public CommentListInfo queryCommentList(String newsId, String newsLink,
			String curPage) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("newsId", newsId));
		params.add(new StringParameter("newsLink", newsLink));
		params.add(new StringParameter("curPage", curPage));
		String json = null;
		try {
			json = getJsonByGet(Constant.QUERY_COMMENT_LIST, params);
			// Logger.i(TAG, "评论的当前 的video的.json="+json);
			Logger.i(TAG, "获取当前视频评论newsId=" + newsId + "newsLink=" + newsLink
					+ "curPage=" + curPage);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, CommentListInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 提交评论(v1)
	 * 
	 * @param newsId
	 *            新闻ID
	 * @param newsLink
	 *            新闻播放页url
	 * @param curPage
	 *            第几页(默认值0)
	 * @param content
	 *            评论内容（需要URLEncode）
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public CommentListInfo saveComment(String newsId, String newsLink,
			String curPage, String content, String userId)
			throws ServicesException {
		String s = null;
		try {

			s = URLEncoder.encode(content, "UTF-8");
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
			throw new ServicesException("发送内容包含非法字符");
		}
		content = s;
		// Logger.i(TAG,
		// "发送新闻评论时——参数：newsId="+newsId+" newsLink="+newsLink+" curPage="+curPage+" content="+content+" userId="+userId);

		ParameterList params = new ParameterList();
		params.add(new StringParameter("newsId", newsId));
		params.add(new StringParameter("newsLink", newsLink));
		params.add(new StringParameter("curPage", curPage));
		params.add(new StringParameter("content", content));
		// params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("userid", userId));
		Logger.i(TAG, "newsId=" + newsId + "newsLink=" + newsLink + "curPage="
				+ curPage + "content=" + content + "userid=" + userId);
		String json = null;
		try {
			json = getJsonByGet(Constant.SAVE_COMMENT, params);
			// Logger.i(TAG, "发表新闻评论服务器给返回的.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, CommentListInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 查询头条视频是否举报
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @return
	 * @throws ServicesException
	 */
	public VideoReportInfo queryVideoReportByNews(String userId, String videoId)
			throws ServicesException {
		return queryVideoReport(userId, videoId, "0");
	}

	/**
	 * 查询V拍客视频是否举报
	 * 
	 * @param userId
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public VideoReportInfo queryVideoReportByPaike(String userId, String videoId)
			throws ServicesException {
		return queryVideoReport(userId, videoId, "1");
	}

	/**
	 * 查询视频是否举报
	 * 
	 * @param userId
	 * @param videoId
	 * @param stype
	 *            0 表示新闻 1 表示拍客视频
	 * @return
	 * @throws ServicesException
	 */
	private VideoReportInfo queryVideoReport(String userId, String videoId,
			String stype) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("stype", stype));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_VIDEO_REPORT, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, VideoReportInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 视频举报 ,头条
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addVideoReportByNews(String userId, String videoId)
			throws ServicesException {
		return addVideoReport(userId, videoId, "0");
	}

	/**
	 * 视频举报,V拍客
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addVideoReportByPaike(String userId, String videoId)
			throws ServicesException {
		return addVideoReport(userId, videoId, "1");
	}

	/**
	 * 视频举报
	 * 
	 * @param userId
	 * @param videoId
	 * @param stype
	 *            0 表示新闻 1 表示拍客视频
	 * @return
	 * @throws ServicesException
	 */
	private Boolean addVideoReport(String userId, String videoId, String stype)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("stype", stype));
		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_VIDEO_REPORT, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 查询是否视频收藏
	 * 
	 * @param userId
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public VideoCollectionInfo queryCollectionVideo(String userId,
			String videoId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_COLLECTION_VIDEO, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, VideoCollectionInfo.class);
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 看头条视频收藏
	 * 
	 * @param userId
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean collectionVideoByNews(String userId, String videoId,
			String videoJson) throws ServicesException {
		return collectionVideo(userId, videoId, videoJson, "0");
	}

	/**
	 * 拍客视频收藏
	 * 
	 * @param userId
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean collectionVideoByPaike(String userId, String videoId)
			throws ServicesException {
		return collectionVideo(userId, videoId, "", "1");
	}

	/**
	 * 视频收藏
	 * 
	 * @param userId
	 * @param videoId
	 * @param stype
	 *            0 表示新闻 1 表示拍客视频
	 * @return
	 * @throws ServicesException
	 */
	private Boolean collectionVideo(String userId, String videoId,
			String videoJson, String stype) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("stype", stype));
		params.add(new StringParameter("videoJson", videoJson));
		String json = null;
		try {
			Logger.i(TAG, "看头条视频收藏：videoId==" + videoId + "_stype=" + stype);
			json = getJsonByPost(Constant.COLLECTION_VIDEO, params);
			Logger.i(TAG, "收藏视频后，返回的结果：json=" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 视频取消收藏
	 * 
	 * @param userId
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean deletCollectionVideo(String userId, String videoId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.DELET_COLLECTION_VIDEO, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 视频详情（请求v1）
	 * 
	 * @param url
	 *            地址
	 * @return
	 * @throws ServicesException
	 */
	public VideoDetailInfo getVideoDetail(String url) throws ServicesException {
		String json = null;
		try {
			json = getJsonByGet(Constant.QUERY_VIDEO_DETAIL_LIST + "?url="
					+ url, null);
			Logger.i(TAG, "url==" + url);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (json != null) {
			Gson gson = new Gson();
			if (json.contains(Constant.RESULT)) {
				ResultInfo errorInfo = gson.fromJson(json, ResultInfo.class);
				throw new ServicesException(errorInfo.getMessage());
			} else {
				try {
					return gson.fromJson(json, VideoDetailInfo.class);
				} catch (JsonSyntaxException e) {
					e.printStackTrace();
					throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
				}
			}
		} else {
			return null;
		}
	}

	/**
	 * 3期消息红点
	 * 
	 * @param url
	 * @return
	 * @throws ServicesException
	 */
	public MessageRedPointPageInfo getMessageRedPoint(String userId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			Logger.i(TAG, "消息红点为数据userId=" + userId);
			json = getJsonByPost(Constant.OPTION_MESSAGE_RED_POINT, params);
			Logger.i(TAG, "消息红点json==" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (json != null) {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, MessageRedPointPageInfo.class);
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 视频详情中的拍客视频列表
	 * 
	 * @param videoId
	 *            视频id
	 * @return
	 * @throws ServicesException
	 */
	public List<VideoForPaikeInfo> getHeadlinesQueryVideoDetailslist(
			String videoId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.HEADLINES_QUERY_VIDEO_DETAILS_LIST,
					params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (json != null) {
			Gson gson = new Gson();
			VideoDetailsPaikeVideoListInfo detailsInfo = null;
			try {
				detailsInfo = gson.fromJson(json,
						VideoDetailsPaikeVideoListInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
			if (Constant.RESULT_CODE_FAIL.equals(detailsInfo.getResult()
					.getCode())) {
				throw new ServicesException(detailsInfo.getResult()
						.getMessage());
			} else {
				return detailsInfo.getVideo_list();
			}
		} else {
			return null;
		}
	}

	/**
	 * 查询v拍客视频详情 三期的方法
	 * 
	 * @param videoId
	 * @param userId
	 *            未登录用户为空
	 * @return
	 * @throws ServicesException
	 */
	public PaikeVideoDetailPageInfo3 queryVPaikeVideoDetails3(String videoId,
			String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		// videoId = "1247944";
		// userId = "35426";
		params.add(new StringParameter("videoId", videoId));
		if (!TextUtils.isEmpty(userId)) {
			params.add(new StringParameter("userId", userId));
		} else {
			params.add(new StringParameter("userId", ""));
		}

		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_V1VIDEO_DETAILS3, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, PaikeVideoDetailPageInfo3.class);
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 查询v拍客视频详情 三期的方法,静态的
	 * 
	 * @param videoId
	 * @param userId
	 *            未登录用户为空
	 * @return
	 * @throws ServicesException
	 */
	public PaikeVideoDetailPageInfo3 queryVPaikeVideoDetails3OfStatic(
			String videoId, String userId) throws ServicesException {

		String json = null;
		String url = Constant.QUERY_V1VIDEO_DETAILS3_STATIC + videoId + ".json";
		try {
			// json = getJsonByPost(Constant.QUERY_V1VIDEO_DETAILS3, params);
			json = getJsonByGet(url, null);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				return gson.fromJson(json, PaikeVideoDetailPageInfo3.class);
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 添加或取消关注
	 * 
	 * @param userId
	 *            用户id
	 * @param focusUserId
	 *            关注用户id
	 * @param typeId
	 *            (1 添加关注，2 取消关注)
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addorCancelAttention(String userId, String focusUserId,
			String typeld) throws ServicesException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("focusUserId", focusUserId));
		params.add(new StringParameter("typeId", typeld));
		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_OR_CANCEL_ATTENTION, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					throw new ServicesException(objectInfo.getResult()
							.getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 视频点“赞”提交
	 * 
	 * @param newsId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addVideoPraise(String videoId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_VIDEO_PRAISE, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 解除绑定
	 * 
	 * @param userId
	 * @param v1ssoId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean removBind(String userId, String v1ssoId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("v1sso_id", v1ssoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.MAIN_REMOVEBIND, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS_V1.equals(objectInfo
						.getResult().getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 新浪微博登录
	 * 
	 * @param token
	 * @param token_expiretime
	 *            //剩余时间秒值（和各个平台sdk对应）
	 * @param openid
	 * @param access_ip
	 * @param token_expiredate
	 *            //到期时间 yyyy-MM-dd HH:mm:ss（可能需要格式化）
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public LoginInfo sinaWeiboLoginSSO(Context context, String token,
			long token_expiretime, String openid, String access_ip,
			long token_expiredate/* ,String userId */, String nickname,
			String icon) throws ServicesException {
		return loginSSO(context, Constant.BINDING_TYPE_SINA, token,
				token_expiretime + "", openid, access_ip,
				Utils.getParseTime(token_expiredate)/* , userId */, nickname,
				icon);
	}

	/**
	 * 腾讯微博登录
	 * 
	 * @param token
	 * @param token_expiretime
	 *            //剩余时间秒值（和各个平台sdk对应）
	 * @param openid
	 * @param access_ip
	 * @param token_expiredate
	 *            //到期时间 yyyy-MM-dd HH:mm:ss（可能需要格式化）
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public LoginInfo tencentWeiboLoginSSO(Context context, String token,
			long token_expiretime, String openid, String access_ip,
			long token_expiredate/* ,String userId */, String nickname,
			String icon) throws ServicesException {
		return loginSSO(context, Constant.BINDING_TYPE_TENCENT, token,
				token_expiretime + "", openid, access_ip,
				Utils.getParseTime(token_expiredate)/* , userId */, nickname,
				icon);
	}

	/**
	 * 腾讯微博登录
	 * 
	 * @param token
	 * @param token_expiretime
	 *            //剩余时间秒值（和各个平台sdk对应）
	 * @param openid
	 * @param access_ip
	 * @param token_expiredate
	 *            //到期时间 yyyy-MM-dd HH:mm:ss（可能需要格式化）
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public LoginInfo wechatLoginSSO(Context context, String token,
			long token_expiretime, String openid, String access_ip,
			long token_expiredate/* ,String userId */, String nickname,
			String icon) throws ServicesException {
		return loginSSO(context, Constant.BINDING_TYPE_WECHAT, token,
				token_expiretime + "", openid, access_ip,
				Utils.getParseTime(token_expiredate)/* , userId */, nickname,
				icon);
	}

	/**
	 * QQ互联登录
	 * 
	 * @param context
	 * @param token
	 * @param token_expiretime
	 * @param openid
	 * @param access_ip
	 * @param token_expiredate
	 * @return
	 * @throws ServicesException
	 */
	public LoginInfo QQHuLianLoginSSO(Context context, String token,
			long token_expiretime, String openid, String access_ip,
			long token_expiredate/* ,String userId */, String nickname,
			String icon) throws ServicesException {
		// return loginSSO_qq(context, Constant.BINDING_TYPE_QQ, token,
		// token_expiretime + "", openid, access_ip,
		// Utils.getParseTime(token_expiredate)/* , userId */);
		return loginSSO(context, Constant.BINDING_TYPE_QQ, token,
				token_expiretime + "", openid, access_ip,
				Utils.getParseTime(token_expiredate)/* , userId */, nickname,
				icon);
	}

	/**
	 * 
	 * @param context
	 * @param token
	 * @param openid
	 * @param access_ip
	 * @param nickname
	 * @param icon
	 * @return
	 * @throws ServicesException
	 */
	public LoginInfo HuaWeiLoginSSO(Context context, String token,
			String token_expiretime, String openid, String access_ip,
			String token_expiredate, String nickname, String icon)
			throws ServicesException {
		return loginSSO(context, Constant.BINDING_TYPE_HUAWEI, token,
				token_expiretime, openid, access_ip, token_expiredate,
				nickname, icon);
	}

	/**
	 * 第三方登录
	 * 
	 * @return
	 * @throws ServicesException
	 */
	private LoginInfo loginSSO(Context context, String logintype, String token,
			String token_expiretime, String openid, String access_ip,
			String token_expiredate/* ,String userId */, String nickname,
			String icon) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("logintype", logintype));
		params.add(new StringParameter("token", token));
		params.add(new StringParameter("token_expiretime", token_expiretime));
		params.add(new StringParameter("openid", openid));
		params.add(new StringParameter("source_type", "1"));
		params.add(new StringParameter("source_platform", "2"));
		params.add(new StringParameter("access_ip", access_ip));
		params.add(new StringParameter("token_expiredate", token_expiredate));
		params.add(new StringParameter("nickname", nickname));
		params.add(new StringParameter("avatar_path", icon));
		// params.add(new StringParameter("userId",userId));
		params.toString();
		String json = null;
		LoginInfo loginInfo = LoginInfo.getInstance();
		try {
			json = getJsonByPost(Constant.MAIN_LOGINSSO, params);
			// Logger.i(TAG, "第三方登录服务器返回的.json=="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				// Gson gson = new Gson();
				// return gson.fromJson(json, UserInfo.class);
				boolean isLoginState = false;
				JSONObject jsonObj = new JSONObject(json);
				JSONObject result = jsonObj.getJSONObject("result");
				loginInfo.setCode(result.getString("code"));
				loginInfo.setMsg(result.getString("message"));

				if (loginInfo.getCode().equals("1")) {

					loginInfo.setUserId(jsonObj.getString("userId"));
					loginInfo.setUserName(jsonObj.getString("userName"));
					if (jsonObj.has("nickname")) {
						loginInfo.setNickName(jsonObj.getString("nickname"));
					}
					loginInfo.setLoginName("");
					loginInfo.setLoginPw("");
					loginInfo.setUserImg(jsonObj.getString("userImg"));

					loginInfo.setDetail("");
					loginInfo.setSex("");
					loginInfo.setRegion("");
					loginInfo.setState("");
					loginInfo.setCreateTime("");
					loginInfo.setLastloginTime("");
					loginInfo.setVideos("");
					loginInfo.setComments("");
					loginInfo.setShare("");
					loginInfo.setEditor("");

					// "userId": "3291",
					// "sessionId": "50AB6669CEFA6DB446073B2D2C00D337",
					// "userName": "新浪微博3059",
					// "userImg": "http://tp4.sinaimg.cn/3616573323/50/0/1",
					if (jsonObj.has("isuser")) {
						JSONObject isuserObj = jsonObj.getJSONObject("isuser");
						IsuserInfo isuserInfo = new IsuserInfo();
						isuserInfo.setMobileno(isuserObj.getString("mobileno"));
						boolean isSetUserName = isuserObj
								.getBoolean("iseditusername");// true表示没有修改过，可以修改。false反之
						isuserInfo.setIseditusername(isSetUserName);
						// LoginInfo.getInstance().setLoginState(LoginInfo.LOGIN);
						// if(!isSetUserName){
						// isLoginState = true;
						// }
						// LoginInfo.getInstance().setSetUserName(!isSetUserName);
						LoginInfo.getInstance().setIsuser(isuserInfo);
					}
					if (jsonObj.has("Bangdinglist")) {
						// Logger.i(TAG, "sonObj.has(Bangdinglist)");
						JSONArray bindArray = jsonObj
								.getJSONArray("Bangdinglist");
						ArrayList<BindInfo> bindList = new ArrayList<BindInfo>();
						for (int i = 0; i < bindArray.length(); i++) {

							String jsonStr = bindArray.getString(i);
							Gson gson = new Gson();
							BindInfo bindInfo = gson.fromJson(jsonStr,
									BindInfo.class);
							bindInfo.setInfoString(jsonStr);
							bindList.add(bindInfo);
							loginInfo.setBangdinglist(bindList);
						}
					}
					loginInfo.setLogin(true);
					// if(isLoginState){
					// loginInfo.setLoginState(LoginInfo.LOGIN);
					// }else{
					loginInfo.setLoginState(LoginInfo.THIRDPARTY_LOGIN);
					// }
					loginInfo.saveInstance(context);
					return loginInfo;

				} else {
					return loginInfo;
				}
			} catch (JSONException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	// @Deprecated
	// private UserInfo login(String username, String pwd) throws
	// ServicesException {
	// ParameterList params = new ParameterList();
	// params.add(new StringParameter("username",username));
	// params.add(new StringParameter("pwd",pwd));
	// String json = null;
	// try {
	// json = getJsonByPost(Constant.LOGIN, params);
	// } catch (NetException e) {
	// throw new ServicesException(e.getMessage());
	// }
	// if (TextUtils.isEmpty(json)) {
	// return null;
	// } else {
	// try {
	// Gson gson = new Gson();
	// return gson.fromJson(json, UserInfo.class);
	// } catch (JsonSyntaxException e) {
	// e.printStackTrace();
	// throw new ServicesException("服务器返回数据错误");
	// }
	// }
	// }

	/**
	 * 登录接口
	 * 
	 * @param username
	 * @param pwd
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public LoginInfo getLoginInfo(Context context, String username, String pwd)
			throws NetException, JSONException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("username", username));
		params.add(new StringParameter("pwd", pwd));
		// Logger.i(TAG, "username="+username);
		// Logger.i(TAG, "pwd="+pwd);
		String json = null;
		LoginInfo loginInfo = LoginInfo.getInstance();
		json = getJsonByPost(Constant.LOGIN, params);
		Logger.i(TAG, "登录json==" + json);
		if (json == null) {
			return null;
		} else {
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");
			loginInfo.setCode(result.getString("code"));
			loginInfo.setMsg(result.getString("message"));

			if (loginInfo.getCode().equals("1")) {

				loginInfo.setUserId(jsonObj.getString("userId"));
				loginInfo.setUserName(jsonObj.getString("userName"));
				loginInfo.setLoginName(username);
				if (jsonObj.has("nickname")) {
					loginInfo.setNickName(jsonObj.getString("nickname"));
				}
				loginInfo.setLoginPw(pwd);
				loginInfo.setUserImg(jsonObj.getString("userImg"));
				loginInfo.setDetail(jsonObj.getString("detail"));
				loginInfo.setSex(jsonObj.getString("sex"));
				loginInfo.setRegion(jsonObj.getString("region"));
				loginInfo.setState(jsonObj.getString("state"));
				loginInfo.setCreateTime(jsonObj.getString("createTime"));
				loginInfo.setLastloginTime(jsonObj.getString("lastloginTime"));
				loginInfo.setVideos(jsonObj.getString("videos"));
				loginInfo.setComments(jsonObj.getString("comments"));
				loginInfo.setShare(jsonObj.getString("share"));
				loginInfo.setEditor(jsonObj.getString("editor"));
				if (jsonObj.getString("backgroundImg") != null) {
					loginInfo
							.setUserBackImg(jsonObj.getString("backgroundImg"));
				}
				if (jsonObj.getString("isCertification") != null) {
					loginInfo.setIsCertification(jsonObj
							.getString("isCertification"));
				}
				if (jsonObj.has("isuser")) {
					JSONObject isuserObj = jsonObj.getJSONObject("isuser");
					IsuserInfo isuserInfo = new IsuserInfo();
					isuserInfo.setMobileno(isuserObj.getString("mobileno"));
					isuserInfo.setIseditusername(isuserObj
							.getBoolean("iseditusername"));
					LoginInfo.getInstance().setIsuser(isuserInfo);
				}
				if (jsonObj.has("Bangdinglist")) {

					JSONArray bindArray = jsonObj.getJSONArray("Bangdinglist");
					ArrayList<BindInfo> bindList = new ArrayList<BindInfo>();
					for (int i = 0; i < bindArray.length(); i++) {

						String jsonStr = bindArray.getString(i);
						Gson gson = new Gson();
						BindInfo bindInfo = gson.fromJson(jsonStr,
								BindInfo.class);
						bindInfo.setInfoString(jsonStr);
						bindList.add(bindInfo);
						loginInfo.setBangdinglist(bindList);
					}

				}
				loginInfo.setLogin(true);
				loginInfo.setLoginState(LoginInfo.LOGIN);
				loginInfo.setSetUserName(true);
				Logger.i(TAG, "登录解析方法");
				loginInfo.saveInstance(context);
				return loginInfo;
			} else {
				return loginInfo;
			}
		}
	}

	/**
	 * 获取验证码接口
	 * 
	 * @param mobileno
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo getVcode(String mobileno, String isexist)
			throws NetException, JSONException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("mobileno", mobileno));
		params.add(new StringParameter("isexist", isexist));
		String json = null;
		json = getJsonByPost(Constant.GET_VCODE, params);
		if (json == null) {
			return null;

		} else {

			BaseInfo baseInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			baseInfo.setCode(result.getString("code"));
			baseInfo.setMsg(result.getString("message"));
			return baseInfo;

		}
	}

	/**
	 * 发送验证码接口
	 * 
	 * @param mobileno
	 * @param vcode
	 * @param type
	 *            “1” 注册 2 忘记密码
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo sendVcode(String mobileno, String vcode, String type)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("mobileno", mobileno));
		params.add(new StringParameter("vcode", vcode));
		params.add(new StringParameter("isexist", type));
		String json = null;
		json = getJsonByPost(Constant.SEND_VCODE, params);

		if (json == null || json.equals("")) {
			// Logger.i("222", "发送验证 码.json1111=="+json);
			return null;

		} else {
			// Logger.i("222", "发送验证 码.json=="+json);
			BaseInfo baseInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			baseInfo.setCode(result.getString("code"));
			baseInfo.setMsg(result.getString("message"));
			if (jsonObj.has("userId")) {
				baseInfo.setUserId(jsonObj.getString("userId"));
			}
			return baseInfo;

		}

	}

	/**
	 * 发送验证码和密码 3期
	 * 
	 * @param mobileno
	 * @param vcode
	 * @param type
	 * @param password
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo sendVcodeWithPassword(String mobileno, String vcode,
			String type, String password) throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("mobileno", mobileno));
		params.add(new StringParameter("vcode", vcode));
		params.add(new StringParameter("isexist", type));
		params.add(new StringParameter("pwd", password));
		String json = null;
		json = getJsonByPost(Constant.SEND_VCODE_WITH_PASSWORD, params);

		if (json == null || json.equals("")) {
			// Logger.i("222", "发送验证 码.json1111=="+json);
			return null;

		} else {
			// Logger.i("222", "发送验证 码.json=="+json);
			BaseInfo baseInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");
			baseInfo.setCode(result.getString("code"));
			baseInfo.setMsg(result.getString("message"));

			if (jsonObj.has("userId")) {
				baseInfo.setUserId(jsonObj.getString("userId"));
			}
			return baseInfo;

		}

	}

	/**
	 * 
	 * 注册
	 * 
	 * @param mobile
	 * @param username
	 * @param pwd
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo register(String mobile, String username, String pwd)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("mobile", mobile));
		params.add(new StringParameter("username", username));
		params.add(new StringParameter("pwd", pwd));
		String json = null;
		json = getJsonByPost(Constant.REGISTER, params);
		if (json == null) {
			return null;
		} else {

			BaseInfo registerInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			registerInfo.setCode(result.getString("code"));
			registerInfo.setMsg(result.getString("message"));
			return registerInfo;
		}
	}

	/**
	 * 
	 * 注册
	 * 
	 * @param mobile
	 * @param username
	 * @param pwd
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	// public BaseInfo register(String mobile, String username, String
	// pwd,String type) throws NetException, JSONException{
	//
	// try {
	// URL url =new URL(Constant.REGISTER +
	// "?mobile="+mobile+"&username="+username+"&pwd="+pwd);
	// HttpURLConnection con=(HttpURLConnection)url.openConnection();
	// // con.setDoInput(true);
	// // con.setDoOutput(true);
	// // con.setUseCaches(false);
	// /* 设置传送的method=POST */
	// con.setRequestMethod("POST");
	// /* setRequestProperty */
	// con.setRequestProperty("Connection", "Keep-Alive");
	// con.setRequestProperty("Charset", "UTF-8");
	// // con.setRequestProperty("Charset", "iso8859_1");
	// // con.setRequestProperty("Content-Type",
	// // "application/octet-stream");
	// /* 设置DataOutputStream */
	//
	// /* 取得Response内容 */
	// InputStream is = con.getInputStream();
	// int ch;
	// StringBuffer b =new StringBuffer();
	// while( ( ch = is.read() ) !=-1 )
	// {
	// b.append( (char)ch );
	// }
	//
	// String resJson = b.toString();
	// // String resJson = new String(b,"UTF-8");
	// Logger.i("TAG", "注册+上传头像返回数据.jso="+resJson);
	// if(resJson != null && !resJson.equals("")){
	// // JSONObject jsonObj = new JSONObject(resJson);
	// // JSONObject result = jsonObj.getJSONObject("result");
	// // if(result.getString("code").equals("0")){
	// // return jsonObj.getString("userImg");
	// // }
	// BaseInfo registerInfo = new BaseInfo();
	// JSONObject jsonObj = new JSONObject(resJson);
	// JSONObject result = jsonObj.getJSONObject("result");
	//
	// registerInfo.setCode(result.getString("code"));
	// registerInfo.setMsg(result.getString("message"));
	// return registerInfo;
	// }
	// return null;
	// //
	// } catch (Exception e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	// return null;
	// }

	public BaseInfo register(String mobile, String username, String pwd,
			String type, String nickName) throws NetException, JSONException {

		try {
			URL url = new URL(Constant.REGISTER + "?mobile=" + mobile
					+ "&username=" + username + "&pwd=" + pwd + "&nickname="
					+ nickName);
			Logger.i(TAG, "url.tostring=" + url.toString());
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			// con.setDoInput(true);
			// con.setDoOutput(true);
			// con.setUseCaches(false);
			/* 设置传送的method=POST */
			con.setRequestMethod("POST");
			/* setRequestProperty */
			con.setRequestProperty("Connection", "Keep-Alive");
			con.setRequestProperty("Charset", "UTF-8");
			// con.setRequestProperty("Charset", "iso8859_1");
			// con.setRequestProperty("Content-Type",
			// "application/octet-stream");
			/* 设置DataOutputStream */

			/* 取得Response内容 */
			// InputStream is = con.getInputStream();
			// int ch;
			// StringBuffer b =new StringBuffer();
			// while( ( ch = is.read() ) !=-1 )
			// {
			// b.append( (char)ch );
			// }
			RequestHandler requestHandler = new BasicRequestHandler() {
			};
			HttpResponse httpResponse = requestHandler.readInputStream(con);
			if (httpResponse == null) {
				httpResponse = new HttpResponse(con, null);
			}
			String resJson = httpResponse.getBodyAsString();
			// String resJson = b.toString();
			// String resJson = URLEncoder.encode(b.toString(),"UTF-8");
			// Logger.i("TAG", "注册+上传头像返回数据.json="+resJson);
			if (TextUtils.isEmpty(resJson)) {
				return null;
			} else {
				Gson gson = new Gson();
				try {
					RegistPageInfo info = gson.fromJson(resJson,
							RegistPageInfo.class);
					if (Constant.RESULT_CODE_SUCCESS_V1.equals(info.getResult()
							.getCode())) {
						BaseInfo registerInfo = new BaseInfo();
						registerInfo.setCode(info.getResult().getCode());
						registerInfo.setMsg(info.getResult().getMessage());
						return registerInfo;
					} else {
						BaseInfo registerInfo = new BaseInfo();
						registerInfo.setCode(info.getResult().getCode());
						registerInfo.setMsg(info.getResult().getMessage());
						return registerInfo;
					}
				} catch (JsonSyntaxException e) {
					throw new ServicesException("服务器返回数据错误");
				}
			}

			//
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public BaseInfo registerWithHead(File file, String mobile, String username,
			String pwd, String nickName) {

		// String end ="\r\n";
		// String twoHyphens ="--";
		// String boundary ="*****";
		// if(file != null){
		// Logger.i("TAG", "上传时file!=null__file.size=="+file.length());
		// }else{
		// Logger.i("TAG", "上传时file==null");
		// }
		try {
			URL url = new URL(Constant.REGISTER + "?mobile=" + mobile
					+ "&username=" + username + "&pwd=" + pwd + "&nickname="
					+ nickName);
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			con.setDoInput(true);
			con.setDoOutput(true);
			con.setUseCaches(false);
			/* 设置传送的method=POST */
			con.setRequestMethod("POST");
			// String URLENCODED =
			// "application/x-www-form-urlencoded;charset=UTF-8";
			// String MULTIPART = "multipart/form-data";
			/* setRequestProperty */
			con.setRequestProperty("Connection", "Keep-Alive");
			con.setRequestProperty("Charset", "UTF-8");
			// con.setRequestProperty("Charset", "iso8859_1");
			// con.setRequestProperty("Content-Type",//ft_5.29修改成下面的流文件
			// "multipart/form-data;boundary="+boundary);
			con.setRequestProperty("Content-Type", "application/octet-stream");
			/* 设置DataOutputStream */
			DataOutputStream ds = new DataOutputStream(con.getOutputStream());
			// ds.writeBytes(twoHyphens + boundary + end);//ft_5.29修改
			// ds.writeBytes("Content-Disposition: form-data; "+//ft_5.29修改
			// "name=\"file1\";filename=\""+
			// file.getName() +"\""+ end);
			// ds.writeBytes(end);//ft_5.29修改
			/* 取得文件的FileInputStream */
			FileInputStream fStream = new FileInputStream(file);
			/* 设置每次写入1024bytes */
			int bufferSize = 1024;
			byte[] buffer = new byte[bufferSize];
			int length = -1;
			/* 从文件读取数据至缓冲区 */
			while ((length = fStream.read(buffer)) != -1) {
				/* 将资料写入DataOutputStream中 */
				ds.write(buffer, 0, length);
			}
			// ds.writeBytes(end);//ft_5.29修改
			// ds.writeBytes(twoHyphens + boundary + twoHyphens +
			// end);//ft_5.29修改
			/* close streams */
			// fStream.close();
			ds.flush();
			fStream.close();
			/* 取得Response内容 */
			InputStream is = con.getInputStream();
			int ch;
			StringBuffer b = new StringBuffer();
			while ((ch = is.read()) != -1) {
				b.append((char) ch);
			}
			/* 关闭DataOutputStream */
			ds.close();
			//
			String resJson = b.toString();
			// String resJson = new String(b,"UTF-8");
			// Logger.i("TAG", "注册+上传头像返回数据.jso="+resJson);
			if (resJson != null && !resJson.equals("")) {
				// JSONObject jsonObj = new JSONObject(resJson);
				// JSONObject result = jsonObj.getJSONObject("result");
				// if(result.getString("code").equals("0")){
				// return jsonObj.getString("userImg");
				// }
				BaseInfo registerInfo = new BaseInfo();
				JSONObject jsonObj = new JSONObject(resJson);
				JSONObject result = jsonObj.getJSONObject("result");

				registerInfo.setCode(result.getString("code"));
				registerInfo.setMsg(result.getString("message"));
				return registerInfo;
			}
			return null;
			//
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;

	}

	/**
	 * 向服务器发送通讯录信息
	 * 
	 * @param userId
	 * @param addressBook
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo sendContact(String userId, JSONArray addressBook)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("addressBook", addressBook.toString()));
		String json = null;
		json = getJsonByPost(Constant.SEND_CONTACT, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo contactInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			contactInfo.setCode(result.getString("code"));
			contactInfo.setMsg(result.getString("message"));
			return contactInfo;

		}

	}

	/**
	 * 查询是否已上传通讯录
	 * 
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public Boolean isQueryUserphone(String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.IS_QUERY_USER_PHONE, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			throw new ServicesException("服务器返回数据错误");
		} else {
			try {
				Gson gson = new Gson();
				IsqueryUserphoneInfo info = gson.fromJson(json,
						IsqueryUserphoneInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(info.getResult()
						.getCode())) {
					String ismobile = info.getIsmobile();
					if (Constant.IS_QUERY_USER_PHONE_YES.equals(ismobile)) {
						return true;
					} else if (Constant.IS_QUERY_USER_PHONE_NO.equals(ismobile)) {
						return false;
					} else {
						throw new ServicesException("服务器返回数据错误");
					}
				} else {
					throw new ServicesException(info.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 
	 * 忘记密码
	 * 
	 * @param userId
	 * @param username
	 * @param pwd
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo resetPwd(String userId, String username, String pwd)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("username", username));
		params.add(new StringParameter("pwd", pwd));
		String json = null;
		json = getJsonByPost(Constant.RESET_PWD, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 关注、取消关注
	 * 
	 * @param userId
	 * @param focusUserId
	 * @param typeId
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo setFocus(String userId, String focusUserId, String typeId)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("focusUserId", focusUserId));
		params.add(new StringParameter("typeId", typeId));
		String json = null;
		json = getJsonByPost(Constant.SET_FO_UNFO, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo focusInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			focusInfo.setCode(result.getString("code"));
			focusInfo.setMsg(result.getString("message"));
			return focusInfo;

		}

	}

	/**
	 * 重设密码
	 * 
	 * @param userId
	 * @param oldpwd
	 * @param newpwd
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo updatePwd(String userId, String oldpwd, String newpwd)
			throws NetException, JSONException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("oldpwd", oldpwd));
		params.add(new StringParameter("newpwd", newpwd));
		String json = null;
		json = getJsonByPost(Constant.UPDATE_PWD, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 个人中心列表信息
	 * 
	 * @param userId
	 * @param sendtype
	 *            1、release 个人页发布 other_release 他人页发布 2、forward 转发 3、collection
	 *            收藏
	 * @param page_index
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public List<VideoInfo> getMyCenterDataList(String userId, String sendtype,
			String page_index) throws NetException, JSONException,
			ServicesException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("sendtype", sendtype));
		params.add(new StringParameter("page_index", page_index));
		if (LoginInfo.getInstance().isLogin()) {
			params.add(new StringParameter("askUserId", LoginInfo.getInstance()
					.getUserId()));
		} else {
			params.add(new StringParameter("askUserId", ""));
		}
		String json = null;

		PersonCenterVideoPageInfo pageInfo = null;
		try {
			json = getJsonByPost(Constant.GET_PERSONAL_DATALIST, params);
			Logger.i("json", "getMyCenterDataList()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				pageInfo = gson.fromJson(json, PersonCenterVideoPageInfo.class);
				if (pageInfo != null) {
					if (Constant.RESULT_CODE_SUCCESS.equals(pageInfo
							.getResult().getCode())) {
						return pageInfo.getVideo_list();
					} else {
						throw new ServicesException(pageInfo.getResult()
								.getMessage());
					}
				} else {
					return null;
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
		// if(json == null){
		// return null;
		//
		// }else{
		// JSONObject jsonObj = new JSONObject(json);
		// List<VideoInfo> videoList = null;
		// if(jsonObj.getJSONObject("result").getString("code").equals("0")){
		// videoList = new ArrayList<VideoInfo>();
		// JSONArray jsonArray= jsonObj.getJSONArray("video_list");
		// for(int i=0; i<jsonArray.length(); i++){
		//
		// JSONObject videoObj = jsonArray.getJSONObject(i);
		// VideoInfo videoInfo = new VideoInfo();
		// videoInfo.setVideoId(videoObj.optString("videoId"));
		// videoInfo.setUserId(videoObj.optString("userId"));
		// videoInfo.setVideoUrl(videoObj.optString("videoUrl"));
		// videoInfo.setImgUrl(videoObj.optString("imgUrl"));
		// videoInfo.setDetail(videoObj.optString("detail"));
		// videoInfo.setUserName(videoObj.optString("userName"));
		// videoInfo.setCreateTime(videoObj.optString("create_time"));
		// videoInfo.setPlayNum(videoObj.optString("playNum"));
		// videoInfo.setPraiseNum(
		// Integer.parseInt(videoObj.getString("praise")));
		// videoInfo.setComments(videoObj.optString("comments"));
		// videoInfo.setForward(videoObj.optString("forward"));
		// videoInfo.setUserImg(videoObj.optString("userImg"));
		// videoInfo.setAddress(videoObj.optString("address"));
		// videoInfo.setSex(videoObj.optString("sex"));
		//
		// videoList.add(videoInfo);
		// }
		//
		// return videoList;
		// }
		// else{
		// return null;
		// }
		//
		// }

	}

	/**
	 * 个人中心数据
	 * 
	 * @param userId
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public MyCenterInfo getMyCenter(String userId) throws NetException,
			JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		json = getJsonByPost(Constant.GET_MY_CENTER, params);
		Logger.i("json", "getMyCenter()\n" + json);
		if (json == null || json.equals("")) {
			return null;

		} else {
			try {
				JSONObject jsonObj = new JSONObject(json);
				if (jsonObj.getJSONObject("result").getString("code")
						.equals("0")) {

					Gson gson = new Gson();
					MyCenterInfo result = gson.fromJson(json,
							MyCenterInfo.class);
					if (result != null) {
						return result;
					} else {
						return null;
					}
				} else {
					return null;
				}
			} catch (Exception ex) {
				throw new NetException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 他人用户主页数据
	 * 
	 * @param other_user_id
	 * @param userId
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public MyCenterInfo getOtherPersonPage(String other_user_id, String userId)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("other_user_id", other_user_id));
		if (userId != null && !userId.equals("")) {
			params.add(new StringParameter("userId", userId));
		}
		String json = null;
		json = getJsonByPost(Constant.GET_OTHERCENTER, params);
		Logger.i("json", "getOtherPersonPage()\n" + json);
		if (json == null) {
			return null;
		} else {
			try {
				JSONObject jsonObj = new JSONObject(json);
				if (jsonObj.getJSONObject("result").getString("code")
						.equals("0")) {
					Gson gson = new Gson();
					MyCenterInfo result = gson.fromJson(json,
							MyCenterInfo.class);
					if (result != null) {
						return result;
					} else {
						return null;
					}

				} else {
					return null;
				}
			} catch (Exception ex) {
				throw new NetException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 修改用户个人信息
	 * 
	 * @param userId
	 * @param detail
	 * @param sex
	 * @param region
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo updateUserInfo(String userId, String detail, String sex,
			String region) throws NetException, JSONException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("detail", detail));
		params.add(new StringParameter("sex", sex));
		params.add(new StringParameter("region", region));
		String json = null;
		json = getJsonByPost(Constant.UPDATE_USERINFO, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 
	 * 
	 * 
	 * @param type
	 * @param opinion
	 * @param contact
	 * @param operator
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo uploadUserOpinion(String type, String opinion,
			String contact, String operator) throws NetException, JSONException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("type", type));
		params.add(new StringParameter("opinion", opinion));
		params.add(new StringParameter("contact", contact));
		params.add(new StringParameter("operator", operator));
		String json = null;
		json = getJsonByPost(Constant.UPDATE_USERINFO, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 上传头像
	 * 
	 * @param file
	 * @return
	 */
	public String sendUserImg(File file) {

		String end = "\r\n";
		String twoHyphens = "--";
		String boundary = "*****";
		// if(file != null){
		// Logger.i("TAG", "上传时file!=null__file.size=="+file.length());
		// }else{
		// Logger.i("TAG", "上传时file==null");
		// }
		try {
			URL url = new URL(Constant.UPDATE_IMG + "?userId="
					+ LoginInfo.getInstance().getUserId());
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			con.setDoInput(true);
			con.setDoOutput(true);
			con.setUseCaches(false);
			/* 设置传送的method=POST */
			con.setRequestMethod("POST");
			/* setRequestProperty */
			con.setRequestProperty("Connection", "Keep-Alive");
			con.setRequestProperty("Charset", "UTF-8");
			// con.setRequestProperty("Content-Type",//ft_5.29修改成下面的流文件
			// "multipart/form-data;boundary="+boundary);
			con.setRequestProperty("Content-Type", "application/octet-stream");

			/* 设置DataOutputStream */
			DataOutputStream ds = new DataOutputStream(con.getOutputStream());
			// ds.writeBytes(twoHyphens + boundary + end);//ft_5.29修改
			// ds.writeBytes("Content-Disposition: form-data; "+//ft_5.29修改
			// "name=\"file1\";filename=\""+
			// file.getName() +"\""+ end);
			// ds.writeBytes(end);//ft_5.29修改
			/* 取得文件的FileInputStream */
			FileInputStream fStream = new FileInputStream(file);
			/* 设置每次写入1024bytes */
			int bufferSize = 1024;
			byte[] buffer = new byte[bufferSize];
			int length = -1;
			/* 从文件读取数据至缓冲区 */
			while ((length = fStream.read(buffer)) != -1) {
				/* 将资料写入DataOutputStream中 */
				ds.write(buffer, 0, length);
			}
			// ds.writeBytes(end);//ft_5.29修改
			// ds.writeBytes(twoHyphens + boundary + twoHyphens +
			// end);//ft_5.29修改
			/* close streams */
			// fStream.close();
			ds.flush();
			fStream.close();
			/* 取得Response内容 */
			InputStream is = con.getInputStream();
			int ch;
			StringBuffer b = new StringBuffer();
			while ((ch = is.read()) != -1) {
				b.append((char) ch);
			}
			/* 关闭DataOutputStream */
			ds.close();
			//
			String resJson = b.toString();
			// String resJson = new String(b,"UTF-8");
			// Logger.i("TAG", "上传头像返回数据.jso="+resJson);
			if (resJson != null && !resJson.equals("")) {
				JSONObject jsonObj = new JSONObject(resJson);
				JSONObject result = jsonObj.getJSONObject("result");
				if (result.getString("code").equals("0")) {
					return jsonObj.getString("userImg");
				}
			}
			return null;
			//
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;

	}

	/**
	 * 上传个人中心背景图片
	 * 
	 * @param file
	 * @return
	 */
	public String sendUserBackImg(File file) {

		String end = "\r\n";
		String twoHyphens = "--";
		String boundary = "*****";
		// if(file != null){
		// Logger.i("TAG", "上传时file!=null__file.size=="+file.length());
		// }else{
		// Logger.i("TAG", "上传时file==null");
		// }
		try {
			URL url = new URL(Constant.UPDATE_BACK_IMG + "?userId="
					+ LoginInfo.getInstance().getUserId());
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			con.setDoInput(true);
			con.setDoOutput(true);
			con.setUseCaches(false);
			/* 设置传送的method=POST */
			con.setRequestMethod("POST");
			/* setRequestProperty */
			con.setRequestProperty("Connection", "Keep-Alive");
			con.setRequestProperty("Charset", "UTF-8");
			// con.setRequestProperty("Content-Type",//ft_5.29修改成下面的流文件
			// "multipart/form-data;boundary="+boundary);
			con.setRequestProperty("Content-Type", "application/octet-stream");

			/* 设置DataOutputStream */
			DataOutputStream ds = new DataOutputStream(con.getOutputStream());
			// ds.writeBytes(twoHyphens + boundary + end);//ft_5.29修改
			// ds.writeBytes("Content-Disposition: form-data; "+//ft_5.29修改
			// "name=\"file1\";filename=\""+
			// file.getName() +"\""+ end);
			// ds.writeBytes(end);//ft_5.29修改
			/* 取得文件的FileInputStream */
			FileInputStream fStream = new FileInputStream(file);
			/* 设置每次写入1024bytes */
			int bufferSize = 1024;
			byte[] buffer = new byte[bufferSize];
			int length = -1;
			/* 从文件读取数据至缓冲区 */
			while ((length = fStream.read(buffer)) != -1) {
				/* 将资料写入DataOutputStream中 */
				ds.write(buffer, 0, length);
			}
			// ds.writeBytes(end);//ft_5.29修改
			// ds.writeBytes(twoHyphens + boundary + twoHyphens +
			// end);//ft_5.29修改
			/* close streams */
			// fStream.close();
			ds.flush();
			fStream.close();
			/* 取得Response内容 */
			InputStream is = con.getInputStream();
			int ch;
			StringBuffer b = new StringBuffer();
			while ((ch = is.read()) != -1) {
				b.append((char) ch);
			}
			/* 关闭DataOutputStream */
			ds.close();
			//
			String resJson = b.toString();
			// String resJson = new String(b,"UTF-8");
			Logger.i("TAG", "上传背景返回数据.json=" + resJson);
			if (resJson != null && !resJson.equals("")) {
				JSONObject jsonObj = new JSONObject(resJson);
				JSONObject result = jsonObj.getJSONObject("result");
				if (result.getString("code").equals("0")) {
					return jsonObj.getString("backgroundImg");
				}
			}
			return null;
			//
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;

	}

	/**
	 * 绑定手机号
	 * 
	 * 
	 * @param userId
	 * @param mobileno
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo bindMobile(String userId, String mobileno)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("mobileno", mobileno));
		String json = null;
		json = getJsonByPost(Constant.BIND_MOBILE, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 手机号解绑
	 * 
	 * @param userId
	 * @param mobileno
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public BaseInfo removeMobile(String userId, String mobileno)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("mobileno", mobileno));
		String json = null;
		json = getJsonByPost(Constant.REMOVE_MOBILE, params);

		if (json == null) {
			return null;

		} else {

			BaseInfo resetInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			resetInfo.setCode(result.getString("code"));
			resetInfo.setMsg(result.getString("message"));
			return resetInfo;

		}

	}

	/**
	 * 判断该第三方用户是否设置过用户名，（为判断是否可以绑定手机的前提）
	 * 
	 * @param userId
	 * @param mobileno
	 * @return
	 * @throws NetException
	 * @throws JSONException
	 */
	public IsEditUserNameInfo isEditUserName(String userId)
			throws NetException, JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		json = getJsonByPost(Constant.EDIT_USERNAME, params);
		// Logger.i(TAG, "判断是否设置过用户名返回的.json="+json);
		if (json == null) {
			return null;

		} else {

			IsEditUserNameInfo editInfo = new IsEditUserNameInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			editInfo.setCode(result.getString("code"));
			editInfo.setMsg(result.getString("message"));
			editInfo.setIseditusername(jsonObj.getBoolean("iseditusername"));
			return editInfo;

		}

	}

	public BaseInfo updateUserBySSO(String userId, String logintype,
			String username, String pwd, String nickName) throws NetException,
			JSONException {

		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("logintype", logintype));
		params.add(new StringParameter("username", username));
		params.add(new StringParameter("nickname", nickName));
		params.add(new StringParameter("pwd", pwd));
		String json = null;
		json = getJsonByPost(Constant.UPUSERBYSSO, params);
		// Logger.i(TAG, "updateUserBySSO方法执行了，返回的json=="+json);
		if (json == null) {
			return null;
		} else {
			BaseInfo editInfo = new BaseInfo();
			JSONObject jsonObj = new JSONObject(json);
			JSONObject result = jsonObj.getJSONObject("result");

			editInfo.setCode(result.getString("code"));
			editInfo.setMsg(result.getString("message"));
			return editInfo;

		}

	}

	/**
	 * 查询v拍客视频评论
	 * 
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public List<VPaikeCommentInfo> queryVideoCommentsList(String videoId,
			String pageIndex) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("page_index", pageIndex));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_VIDEO_COMMENTS_LIST, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				VPaikeCommentListInfo commentListInfo = gson.fromJson(json,
						VPaikeCommentListInfo.class);
				if (commentListInfo != null) {
					if (Constant.RESULT_CODE_SUCCESS.equals(commentListInfo
							.getResult().getCode())) {
						return commentListInfo.getComments_list();
					} else {
						throw new ServicesException(commentListInfo.getResult()
								.getMessage());
					}
				} else {
					return null;
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 查询v拍客视频评论
	 * 
	 * @param videoId
	 * @return
	 * @throws ServicesException
	 */
	public VPaikeCommentListInfo queryVideoCommentsList3(String videoId,
			String pageIndex) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("page_index", pageIndex));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_VIDEO_COMMENTS_LIST, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				VPaikeCommentListInfo commentListInfo = gson.fromJson(json,
						VPaikeCommentListInfo.class);
				if (commentListInfo != null) {
					return commentListInfo;
				} else {
					return null;
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * v拍客视频回复评论 参数 videoId userId comments replyUserId
	 * 
	 * @param userId
	 * @param videoId
	 * @param comments
	 * @param replyUserId
	 *            （如果不是回复别人的评论replyUserId 传null）
	 * @return
	 * @throws ServicesException
	 */
	public Boolean addCommentsForPaike(String userId, String videoId,
			String comments, String replyUserId) throws ServicesException {
		ParameterList params = new ParameterList();
		// Logger.i(TAG,
		// "发表拍客评论时的参数:userid="+userId+" videoId="+videoId+" comments="+comments+" replyUserId="+replyUserId);
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("comments", comments));
		if (!TextUtils.isEmpty(replyUserId))
			params.add(new StringParameter("replyUserId", replyUserId));

		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_COMMENTS, params);
			// Logger.i(TAG, "发表拍客评论返回的。json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					throw new ServicesException(objectInfo.getResult()
							.getMessage());
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 达人（未登录）
	 * 
	 * @param pageIndex
	 *            页码
	 * @return
	 * @throws ServicesException
	 */
	public List<VPaikeRecommendInfo> queryVPaikeUserinfoTalentlist(
			String pageIndex) throws ServicesException {
		return queryVPaikeUserinfoTalentlist(pageIndex, null);
	}

	/**
	 * 达人(登录)
	 * 
	 * @param pageIndex
	 *            页码
	 * @param userId
	 *            未登录不写
	 * @return
	 * @throws ServicesException
	 */
	public List<VPaikeRecommendInfo> queryVPaikeUserinfoTalentlist(
			String pageIndex, String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		if (!TextUtils.isEmpty(userId)) {
			params.add(new StringParameter("userId", userId));
		}
		params.add(new StringParameter("state", "12"));
		params.add(new StringParameter("page_index", pageIndex));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_V1_USERINFO_TALENT_LIST, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				VPaikeRecommendListInfo paikeTalentListInfo = gson.fromJson(
						json, VPaikeRecommendListInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(paikeTalentListInfo
						.getResult().getCode())) {
					return paikeTalentListInfo.getVideo_list();
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 朋友
	 * 
	 * @param userId
	 *            用户id
	 * @return
	 * @throws ServicesException
	 */
	public VPaikeRecommendListInfo getUserByMobile(String userId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_USER_BY_MOBILE, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				VPaikeRecommendListInfo paikeTalentListInfo = gson.fromJson(
						json, VPaikeRecommendListInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(paikeTalentListInfo
						.getResult().getCode())) {
					return paikeTalentListInfo;
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * V拍客身边 --地图显示图标列表
	 * 
	 * @param region
	 *            省/直辖市名称
	 * @return
	 * @throws ServicesException
	 */
	/*
	 * public List<VPaikeBesideVideoInfo> queryBesideVideolist(String region)
	 * throws ServicesException { ParameterList params = new ParameterList();
	 * params.add(new StringParameter("region", region)); // Logger.i(TAG,
	 * "即将获得数据的地区是"+region); String json = null; try { json =
	 * getJsonByPost(Constant.QUERY_BESIDE_VIDEOLIST, params); // Logger.i(TAG,
	 * "已获得数据的地区是"+region+"__返回的.json="+json); } catch (NetException e) { throw
	 * new ServicesException(e.getMessage()); } if (!TextUtils.isEmpty(json)) {
	 * Gson gson = new Gson(); try { VPaikeBesideVideoListInfo
	 * besideVideoListInfo = gson.fromJson( json,
	 * VPaikeBesideVideoListInfo.class); if
	 * (Constant.RESULT_CODE_SUCCESS.equals(besideVideoListInfo
	 * .getResult().getCode())) { return besideVideoListInfo.getBesideingList();
	 * } else { throw new ServicesException(besideVideoListInfo.getResult()
	 * .getMessage()); } } catch (JsonSyntaxException e) { throw new
	 * ServicesException("服务器返回数据错误"); }
	 * 
	 * } else { return null; } }
	 */

	/**
	 * 新闻 分享，分发视频
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @param comments
	 *            文字内容
	 * @return
	 * @throws ServicesException
	 */
	public Boolean shareForwardVideoByNews(String userId, String videoId,
			String comments, String channelVideoInfoJson)
			throws ServicesException {
		return shareForwardVideo(userId, videoId, comments, "0",
				channelVideoInfoJson);
	}

	/**
	 * 拍客 分享，分发视频
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @param comments
	 *            文字内容
	 * @return
	 * @throws ServicesException
	 */
	public Boolean shareForwardVideoByPaike(String userId, String videoId,
			String comments) throws ServicesException {
		return shareForwardVideo(userId, videoId, comments, "1", "");
	}

	/**
	 * 分享，分发视频
	 * 
	 * @param userId
	 *            用户id
	 * @param videoId
	 *            视频id
	 * @param comments
	 *            文字内容
	 * @param stype
	 *            0表示新闻，1表示拍客
	 * 
	 * @channelVideoInfoJson 视频必要信息
	 * @return
	 * @throws ServicesException
	 */
	private Boolean shareForwardVideo(String userId, String videoId,
			String comments, String stype, String channelVideoInfoJson)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("comments", comments));
		params.add(new StringParameter("stype", stype));
		params.add(new StringParameter("videoJson", channelVideoInfoJson));
		String json = null;
		try {
			json = getJsonByPost(Constant.SHARE_FORWARD_VIDEO, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					return false;
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 消息提醒上传设置
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo sendTipsOfMessage(String userId, String type,
			String typeId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("type", type));
		params.add(new StringParameter("value", typeId));
		String json = null;
		try {
			// Logger.i("json",
			// "消息上传的参数="+"userid="+userId+" type="+type+"|"+"typeId="+typeId);
			json = getJsonByPost(Constant.OPTION_MESSAGE_TIPS, params);
			// Logger.i("json", "消息上传的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				CommonPageInfo cl = gson.fromJson(json, CommonPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					return cl.getResult();
				} else {
					throw new ServicesException(cl.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 消息提醒上传设置 二期
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public MessageSwitchPageInfo sendTipsOfMessage2(String userId, String type,
			String status) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("type", type));
		params.add(new StringParameter("status", status));
		String json = null;
		try {
			// Logger.i("json",
			// "消息上传的参数="+"userid="+userId+" type="+type+"|"+"typeId="+typeId);
			json = getJsonByPost(Constant.OPTION_MESSAGE_TIPS2, params);
			// Logger.i("json", "消息上传的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				MessageSwitchPageInfo cl = gson.fromJson(json,
						MessageSwitchPageInfo.class);
				if (cl != null) {
					return cl;
				} else {
					return null;
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 删除视频(发布，分享，收藏)
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo deleteVideoOfCenter(String videoId, String id, String type)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("deleteType", type));
		// params.add(new StringParameter("Id",id));
		if (!type.equals("release")) {
			params.add(new StringParameter("Id", id));
		}
		String json = null;
		try {
			json = getJsonByPost(Constant.OPTION_DELETE_VIDEO, params);
			// Logger.i("json", "删除收藏视频的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				CommonPageInfo cl = gson.fromJson(json, CommonPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					return cl.getResult();
				} else {
					throw new ServicesException(cl.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 意见反馈
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo sendAboutIdea(String opinion, String contact,
			String operator) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("type", "Android"));
		params.add(new StringParameter("opinion", opinion));
		params.add(new StringParameter("contact", contact));
		params.add(new StringParameter("operator", operator));
		String json = null;
		try {
			// Logger.i("json",
			// "意见反馈上传的参数="+"opinion="+opinion+" contact="+contact+"|"+"operator="+operator);
			json = getJsonByPost(Constant.ABOUT_IDEA, params);
			// Logger.i("json", "意见反馈的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				CommonPageInfo cl = gson.fromJson(json, CommonPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					return cl.getResult();
				} else {
					throw new ServicesException(cl.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 测试注册
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public void getTestRegistData() throws Exception {
		ParameterList params = new ParameterList();
		// params.add(new StringParameter("login","Android"));
		String name = "你好";
		String userName = URLEncoder.encode(name, "UTF-8");
		params.add(new StringParameter("username", "1.0.0"));
		params.add(new StringParameter("pwd",
				"96e79218965eb72c92a549dd5a330112"));
		// params.add(new StringParameter("appCode", "13"));
		String json = null;
		String url = "https://111.207.209.63:8443/api/user?login";
		try {
			json = getJsonByPost(url, params);
			// Logger.i("json", "测试注册的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return;
		} else {
			Gson gson = new Gson();
			try {
				// VersionCheckPageInfo cl = gson.fromJson(json,
				// VersionCheckPageInfo.class);
				// if(Constant.RESULT_CODE_SUCCESS.equals(cl.getResult().getCode())){
				// return cl;
				// }else{
				// throw new ServicesException(cl.getResult().getMessage());
				// }
				return;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 检测版本
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public VersionCheckPageInfo getVersionData() throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("versionType", "Android"));

		// params.add(new StringParameter("v", "1.0.0"));
		// params.add(new StringParameter("appCode", "13"));
		String json = null;
		try {
			json = getJsonByPost(Constant.ABOUT_CHECK_UPDATA, params);
			// json = getJsonByPost(url, params);
			// Logger.i("json", "检测版本的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				VersionCheckPageInfo cl = gson.fromJson(json,
						VersionCheckPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					return cl;
				} else {
					throw new ServicesException(cl.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 检测上传标题和简介有没有禁词
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo getUploadConJudge(String title, String detail)
			throws Exception {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("title", title));
		params.add(new StringParameter("detail", detail));
		String json = null;
		try {
			json = getJsonByPost(Constant.VIDEO_UPLOAD_JUDGE, params);
			// Logger.i("json", "上传标题检测返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				UploadJingciPageInfo cl = gson.fromJson(json,
						UploadJingciPageInfo.class);
				// if(Constant.RESULT_CODE_SUCCESS.equals(cl.getResult().getCode())){
				// return cl;
				// }else{
				// throw new ServicesException(cl.getResult().getMessage());
				// }
				if (cl != null) {
					return cl.getResult();
				} else {
					return null;
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 更换第三方头像后，传给服务器
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public int SendHeadToServer(String userId, String headUrl) throws Exception {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("ImageURL", headUrl));
		String json = null;
		try {
			// Logger.i(TAG, "SendHeadToServer本方法执行了……。");
			json = getJsonByPost(Constant.HEAD_UPDATA_TO_SERVE, params);
			// Logger.i(TAG, "上传第三方头像返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return -1;
		} else {
			Gson gson = new Gson();
			try {
				UpdateHeadImgPageInfo cl = gson.fromJson(json,
						UpdateHeadImgPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					return 0;
				} else {
					throw new ServicesException(cl.getResult().getMessage());
				}
				// return -1;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 检测好友是否有更新信息
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public int GetFriendUpdata(String userId, String time) throws Exception {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("datetime", time));
		// Logger.i(TAG, "datetime="+time);
		String json = null;
		try {
			// Logger.i(TAG, "GetFriendUpdata本方法执行了……。");
			json = getJsonByPost(Constant.GET_FRIEND_UPDATA, params);
			// Logger.i(TAG, "获取好友是否有更新信息.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return -1;
		} else {
			Gson gson = new Gson();
			try {
				FriendUpdataPageInfo cl = gson.fromJson(json,
						FriendUpdataPageInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(cl.getResult()
						.getCode())) {
					if (cl.getColNumber().equals("0")) {
						return 0;
					} else if (cl.getColNumber().equals("")) {
						return 0;
					} else {
						return 1;
					}
				} else {
					// throw new ServicesException(cl.getResult().getMessage());
					return -1;
				}
				// return -1;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 获取加载页图片地址
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public LoadingPageInfo getLoadingPage() throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("type", "Android"));
		String json = null;
		try {
			json = getJsonByPost(Constant.loading_page, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				return gson.fromJson(json, LoadingPageInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 获取加载页图片地址
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public LoadingPageInfo getLoadingPage(String url) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("type", "Android"));
		String json = null;
		try {
			json = getJsonByPost(url, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			try {
				Gson gson = new Gson();
				return gson.fromJson(json, LoadingPageInfo.class);
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 用户是否被禁用
	 * 
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public boolean checkIfUserDisable(String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.IF_USER_DISABLE, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			throw new ServicesException("服务器返回数据错误");
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo info = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(info.getResult()
						.getCode())) {
					return false;
				} else if (Constant.RESULT_CODE_USER_DISABLE.equals(info
						.getResult().getCode())) {
					return true;
				} else {
					throw new ServicesException(info.getResult().getMessage());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 保存有趣的人
	 * 
	 * @param userId
	 *            用户id
	 * @param focusUserIds
	 *            由id组成的字符串,逗号分割。例如："id1,id2,id3"
	 * @return
	 * @throws ServicesException
	 */
	public boolean addInterestingMan(String userId, String focusUserIds)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("focusUserIds", focusUserIds));
		String json = null;
		try {
			json = getJsonByPost(Constant.ADD_INTERESTING_MAN, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			throw new ServicesException("服务器未返回数据");
		} else {
			try {
				Gson gson = new Gson();
				ResultObjectInfo objectInfo = gson.fromJson(json,
						ResultObjectInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return true;
				} else {
					throw new ServicesException(objectInfo.getResult()
							.getMessage());
				}
			} catch (JsonSyntaxException e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 查询是否有好友
	 * 
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public int queryIfHasFriend(String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.QUERY_MYV1FOCUSONORFANS, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			throw new ServicesException("服务器未返回数据");
		} else {
			try {
				Gson gson = new Gson();
				MyV1FocusOnorFansInfo objectInfo = gson.fromJson(json,
						MyV1FocusOnorFansInfo.class);
				if (Constant.RESULT_CODE_SUCCESS.equals(objectInfo.getResult()
						.getCode())) {
					return Integer.parseInt(objectInfo.getFocusOnCounts());
				} else {
					throw new ServicesException(objectInfo.getResult()
							.getMessage());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	public ChooseAlbumPageInfo getAlbum(String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_ALBUM_JSON, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				ChooseAlbumPageInfo albumInfo = gson.fromJson(json,
						ChooseAlbumPageInfo.class);
				if (albumInfo != null) {
					return albumInfo;
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	public UserAlbumPageInfo getUserAlbum(String userId, String pageIndex,
			int count) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("page", pageIndex));
		params.add(new StringParameter("rows", "" + count));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_USER_ALBUM_JSON, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				UserAlbumPageInfo albumInfo = gson.fromJson(json,
						UserAlbumPageInfo.class);
				if (albumInfo != null) {
					return albumInfo;
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 获取用户的好友信息，这块是相互关注的
	 * 
	 * @param userId
	 * @param groupId
	 * @return
	 * @throws ServicesException
	 */
	public GetUserFriendPageInfo getUserFriend(String userId, String groupId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("groupId", groupId));
		Logger.i(TAG, "groupId==" + groupId);
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_USER_FRIEND, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				GetUserFriendPageInfo friendPageInfo = gson.fromJson(json,
						GetUserFriendPageInfo.class);
				if (friendPageInfo != null) {
					return friendPageInfo;
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	public GetFriendBySharePageInfo getFriendsByShareVideo(String userId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_FRIEND_BY_SHARE_VIDEO, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				GetFriendBySharePageInfo friendsPageInfo = gson.fromJson(json,
						GetFriendBySharePageInfo.class);
				if (friendsPageInfo != null) {
					return friendsPageInfo;
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 为视频添加专辑
	 * 
	 * @param videoId
	 * @param albumName
	 *            ：专辑名称
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public AddAlbumForVideoPageInfo setAlbumForVideo(String videoId,
			String albumName, String userId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("albumName", albumName));
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_DATA_FOR_ADD_ALBUM, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				AddAlbumForVideoPageInfo addAlbumPage = gson.fromJson(json,
						AddAlbumForVideoPageInfo.class);
				if (addAlbumPage != null) {
					if (addAlbumPage.isSuccess()) {
						return addAlbumPage;
					} else {
						throw new ServicesException(addAlbumPage.getMsg());
					}
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 为视频移除专辑
	 * 
	 * @param videoId
	 * @param albumId
	 * @return
	 * @throws ServicesException
	 */
	public AddAlbumForVideoPageInfo removeAlbumForVideo(String videoId,
			String albumId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("videoId", videoId));
		params.add(new StringParameter("albumId", albumId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_DATA_FOR_REMOVE_ALBUM, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			Gson gson = new Gson();
			try {
				AddAlbumForVideoPageInfo addAlbumPage = gson.fromJson(json,
						AddAlbumForVideoPageInfo.class);
				if (addAlbumPage != null) {
					if (addAlbumPage.isSuccess()) {
						return addAlbumPage;
					} else {
						throw new ServicesException(addAlbumPage.getMsg());
					}
				}
				return null;
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}

		} else {
			return null;
		}
	}

	/**
	 * 圈主审核
	 * 
	 * @param groupId
	 * @param userId
	 * @return
	 * @throws ServicesException
	 */
	public GroupAuditPageInfo getDataOfGroupAudit(String groupId, String userId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("groupId", groupId));
		params.add(new StringParameter("userId", userId));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_DATA_OF_GROUP_AUDIT, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				GroupAuditPageInfo groupPage = gson.fromJson(json,
						GroupAuditPageInfo.class);
				if (groupPage != null) {
					return groupPage;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	public ResultInfo nickNameModifyTo(String nickName, String userId)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		params.add(new StringParameter("nickname", nickName));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_NICKNAME_MODIFY, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultObjectInfo result = gson.fromJson(json,
						ResultObjectInfo.class);
				if (result != null) {
					return result.getResult();
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/** 获取微信的token */
	public WeiXinPageInfo getAccessToken(String code) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("appid", Constant.APP_ID));
		params.add(new StringParameter("secret", Constant.secret));
		params.add(new StringParameter("code", code));
		params.add(new StringParameter("grant_type", "authorization_code"));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_WEIXIN_ACCESSTOKEN, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				WeiXinPageInfo result = gson.fromJson(json,
						WeiXinPageInfo.class);
				if (result != null) {
					return result;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/** 获取我的收益：我的赞赏 */
	public MyShouYiPageInfo getMyshouyiOfMyZanShang(String page, String rows)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", LoginInfo.getInstance()
				.getUserId()));
		params.add(new StringParameter("page", page));
		params.add(new StringParameter("rows", rows));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_MYSHOUYI_MY_ZANSHANG, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				MyShouYiPageInfo result = gson.fromJson(json,
						MyShouYiPageInfo.class);
				if (result != null) {
					return result;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/** 获取我的收益：赞赏他人 */
	public MyShouYiPageInfo getMyshouyiOfZanShangOther(String page, String rows)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", LoginInfo.getInstance()
				.getUserId()));
		params.add(new StringParameter("page", page));
		params.add(new StringParameter("rows", rows));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_MYSHOUYI_ZANSHANG_OTHER, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				MyShouYiPageInfo result = gson.fromJson(json,
						MyShouYiPageInfo.class);
				if (result != null) {
					return result;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/** 获取我的收益：我的提现 */
	public MyShouYiPageInfo getMyshouyiOfTiXian(String page, String rows)
			throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", LoginInfo.getInstance()
				.getUserId()));
		// params.add(new StringParameter("userId", "210147"));
		params.add(new StringParameter("page", page));
		params.add(new StringParameter("rows", rows));
		String json = null;
		try {
			json = getJsonByPost(Constant.GET_MYSHOUYI_MY_TIXIAN, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				MyShouYiPageInfo result = gson.fromJson(json,
						MyShouYiPageInfo.class);
				if (result != null) {
					return result;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 详情页的用户的关注关系
	 * 
	 * @param userId
	 * @param toUserId
	 * @return
	 * @throws ServicesException
	 */
	public VideoDetailOfFocousPageInfo getFocousOfVideoDetail(String userId,
			String videoId) throws ServicesException {
		ParameterList params = new ParameterList();
		params.add(new StringParameter("userId", userId));
		// params.add(new StringParameter("userId", "210147"));
		params.add(new StringParameter("videoId", videoId));
		String json = null;
		try {
			json = getJsonByPost(Constant.PAIKE_VIDEO_DETAIL_FOCOUS_OF_USER,
					params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				VideoDetailOfFocousPageInfo result = gson.fromJson(json,
						VideoDetailOfFocousPageInfo.class);
				if (result != null) {
					return result;
				}
				return null;
			} catch (Exception e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取视频的转码状态
	 * 
	 * @param soruceIds
	 * @return
	 * @throws ServicesException
	 */
	public VideoStateOfUploadPageInfo getVideoStateOfUpload(String soruceIds/*
																			 * ,
																			 * String
																			 * uploadFileName
																			 */)
			throws ServicesException {
		ParameterList params = new ParameterList();
		// params.add(new StringParameter("name", uploadFileName));
		params.add(new StringParameter("userId", LoginInfo.getInstance()
				.getUserId()));
		params.add(new StringParameter("sourceId", soruceIds));
		Logger.i(TAG, "soruceIds==" + soruceIds);
		// params.add(new StringParameter("v", "1.0.0"));
		// params.add(new StringParameter("appCode", "13"));
		String json = null;
		try {

			json = getJsonByPost(Constant.GET_VIDEO_STATE, params);
			// json = getJsonByPost(url, params);
			// Logger.i("json", "检测版本的接口返回数据.json="+json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				VideoStateOfUploadPageInfo cl = gson.fromJson(json,
						VideoStateOfUploadPageInfo.class);
				if (cl != null && cl.getCode() == 1) {
					return cl;
				} else {
					throw new ServicesException(cl.getMsg());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	public VideoToZhuanmaPageInfo setVideoToZhuanMa(Header header)
			throws ServicesException {
		String userid = "";//
		if (LoginInfo.getInstance().getUserIdOld() != null
				&& LoginInfo.getInstance().getUserIdOld().length() > 0) {
			userid = LoginInfo.getInstance().getUserIdOld();
		} else {
			userid = LoginInfo.getInstance().getUserId();
		}
		ParameterList params = new ParameterList();
		// params.add(new StringParameter("name", uploadFileName));
		params.add(new StringParameter("userId", userid));
		params.add(new StringParameter("sourceId", header.sourceid));
		params.add(new StringParameter("name", header.related_Video_Id + ".mp4"));
		params.add(new StringParameter("title", header.title));
		params.add(new StringParameter("detail", header.detail));
		params.add(new StringParameter("duration", header.duration));
		params.add(new StringParameter("location", header.address));
		params.add(new StringParameter("virtualAddress", header.virtualAddress));
		params.add(new StringParameter("size", header.Content_Length));
		params.add(new StringParameter("albumName", header.albumName));
		params.add(new StringParameter("activityId", header.activityId));
		params.add(new StringParameter("categoryId", header.ssotype));
		params.add(new StringParameter("themeSource", header.topicName));
		params.add(new StringParameter("friendsId", header.friendsId));
		params.add(new StringParameter("device", header.deviceType));
		String json = null;
		try {
			json = getJsonByPost(Constant.SET_VIDEO_ZHUANMA, params);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (TextUtils.isEmpty(json)) {
			return null;
		} else {
			Gson gson = new Gson();
			try {
				VideoToZhuanmaPageInfo cl = gson.fromJson(json,
						VideoToZhuanmaPageInfo.class);
				if (cl != null && cl.getCode() == 1) {
					return cl;
				} else {
					throw new ServicesException(cl.getMsg());
				}
			} catch (JsonSyntaxException e) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		}
	}

	/**
	 * 发送post请求，获取返回结果json字符串
	 * 
	 * @param path
	 * @param params
	 * @return
	 * @throws NetException
	 */
	private String getJsonByPost(String path, ParameterList params)
			throws NetException {
		NormalHttpClient mclient = new NormalHttpClient();
		HttpResponse response;
		try {
			response = mclient.post(path, params);
		} catch (HttpRequestException e) {
			e.printStackTrace();
			throw new NetException("网络请求异常，请检查网络");
		}
		String s = response.getBodyAsString();
		Logger.d("json", path + "=" + s);
		return s;
	}

	/**
	 * 发送get请求，获取返回结果json字符串
	 * 
	 * @param path
	 * @param params
	 * @return
	 * @throws NetException
	 */
	private String getJsonByGet(String path, ParameterList params)
			throws NetException {
		NormalHttpClient mclient = new NormalHttpClient();
		HttpResponse response;
		try {
			response = mclient.get(path, params);
		} catch (HttpRequestException e) {
			e.printStackTrace();
			throw new NetException("网络请求异常，请检查网络");
		}
		String s = response.getBodyAsString();
		Logger.d("json", path + "=" + s);
		return s;
	}

	/**
	 * 圈子首页(圈子主页中圈子选项卡,数据获取方法)
	 * 
	 * @return
	 * @throws ServicesException
	 */
	/*
	 * public CategoryPageInfoConfig queryCategoryPageInfo() throws
	 * ServicesException { Logger.i("json", "queryCategoryPageInfo()"); String
	 * json = null; try { json = getJsonByGet(Constant.QUANZI_HOME_QUANZI_DATA,
	 * null); Logger.i("json", "queryCategoryPageInfo()\n" + json); } catch
	 * (NetException e) { throw new ServicesException(e.getMessage()); } if
	 * (!TextUtils.isEmpty(json)) { Gson gson = new Gson(); ResultInfo2 result =
	 * gson.fromJson(json, ResultInfo2.class); if (result.isSuccess()) { try {
	 * JSONObject jsonObj = new JSONObject(json); CategoryPageInfoConfig info =
	 * gson.fromJson( jsonObj.getString("obj"), CategoryPageInfoConfig.class);
	 * return info; } catch (JSONException e) { e.printStackTrace(); throw new
	 * ServicesException("服务器返回数据格式错误"); } catch (JsonSyntaxException e) {
	 * e.printStackTrace(); throw new ServicesException("服务器返回数据错误"); } } else {
	 * throw new ServicesException(result.getMsg()); } } else { return null; } }
	 */

	/**
	 * 热门(最新、最热、评论最多)数据获取方法
	 * 
	 * @param sort
	 *            =>latest 最新 (可不加 默认)|hottest 最热 (可不加)|评论最多 (可不加)
	 * @param order
	 *            =>asc (可不加 升降序 默认 asc)
	 * @param page
	 *            =>当前页 (可不加 默认1)
	 * @param rows
	 *            =>每页显示记录数 (可不加 默认10)
	 * @return
	 * @throws ServicesException
	 */
	/*
	 * public WaterFallDataInfoConfig queryHotVideos(String sort, String order,
	 * String page, String rows) throws ServicesException { String json = null;
	 * Logger.i("json", String.format(
	 * "queryHotVideos(sort:%1$s order:%2$s page:%3$s rows:%4$s)", sort, order,
	 * page, rows)); try { ParameterList params = new ParameterList(); if
	 * (!TextUtils.isEmpty(sort)) params.add(new StringParameter("sort", sort));
	 * if (!TextUtils.isEmpty(order)) params.add(new StringParameter("order",
	 * order)); if (!TextUtils.isEmpty(page)) params.add(new
	 * StringParameter("page", page)); if (!TextUtils.isEmpty(rows))
	 * params.add(new StringParameter("rows", rows)); json =
	 * getJsonByPost(Constant.QUANZI_HOME_HOT_DATA, params); Logger.i("json",
	 * "queryHotVideos()\n" + json); } catch (NetException e) { throw new
	 * ServicesException(e.getMessage()); } if (!TextUtils.isEmpty(json)) { Gson
	 * gson = new Gson(); ResultInfo2 result = gson.fromJson(json,
	 * ResultInfo2.class); if (result.isSuccess()) { try { JSONObject jsonObj =
	 * new JSONObject(json); WaterFallDataInfoConfig info = gson.fromJson(
	 * jsonObj.getString("obj"), WaterFallDataInfoConfig.class); return info; }
	 * catch (JSONException e) { e.printStackTrace(); throw new
	 * ServicesException("服务器返回数据格式错误"); } catch (JsonSyntaxException e) {
	 * e.printStackTrace(); throw new ServicesException("服务器返回数据错误"); } } else {
	 * throw new ServicesException(result.getMsg()); } } else { return null; } }
	 */

	/**
	 * 我的(好友圈、自建圈、关注圈)数据获取方法
	 * 
	 * @param sort
	 *            =>friendGroup 好友圈 (可不加 默认)|ownerGroup 自建圈 (可不加)|focusGroup 关注圈
	 *            (可不加)
	 * @param userId
	 *            =>用户ID 35458 (必填)
	 * @param page
	 *            =>当前页 (可不加 默认1)
	 * @param rows
	 *            =>每页显示记录数 (可不加 默认10)
	 * @return
	 * @throws ServicesException
	 */
	/*
	 * public WaterFallDataInfoConfig queryMyVideos(String sort, String userId,
	 * String page, String rows) throws ServicesException { String json = null;
	 * Logger.i("json", String.format(
	 * "queryMyVideos(sort:%1$s userId:%2$s page:%3$s rows:%4$s)", sort, userId,
	 * page, rows)); try { ParameterList params = new ParameterList(); if
	 * (!TextUtils.isEmpty(sort)) params.add(new StringParameter("sort", sort));
	 * if (!TextUtils.isEmpty(userId)) params.add(new StringParameter("userId",
	 * userId)); if (!TextUtils.isEmpty(page)) params.add(new
	 * StringParameter("page", page)); if (!TextUtils.isEmpty(rows))
	 * params.add(new StringParameter("rows", rows)); json =
	 * getJsonByPost(Constant.QUANZI_HOME_MY_DATA, params); Logger.i("json",
	 * "queryMyVideos()\n" + json); } catch (NetException e) { throw new
	 * ServicesException(e.getMessage()); } if (!TextUtils.isEmpty(json)) { Gson
	 * gson = new Gson(); ResultInfo2 result = gson.fromJson(json,
	 * ResultInfo2.class); if (result.isSuccess()) { try { JSONObject jsonObj =
	 * new JSONObject(json); WaterFallDataInfoConfig info = gson.fromJson(
	 * jsonObj.getString("obj"), WaterFallDataInfoConfig.class); return info; }
	 * catch (JSONException e) { e.printStackTrace(); throw new
	 * ServicesException("服务器返回数据格式错误"); } catch (JsonSyntaxException e) {
	 * e.printStackTrace(); throw new ServicesException("服务器返回数据错误"); } } else {
	 * throw new ServicesException(result.getMsg()); } } else { return null; } }
	 */

	/**
	 * 管理我的圈子 – 创建圈子 – 获取分类
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public List<Category> queryAllCategories() throws ServicesException {
		Logger.i("json", "queryAllCategories()");
		String json = null;
		try {
			json = getJsonByGet(Constant.CREATE_QUANZI_QUERY_CATEGORIES_DATA,
					null);
			Logger.i("json", "queryAllCategories()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					Type type = new TypeToken<ArrayList<Category>>() {
					}.getType();
					JSONObject jsonObj = new JSONObject(json);
					List<Category> categorys = gson.fromJson(
							jsonObj.getString("obj"), type);
					return categorys;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 保存创建圈子
	 * 
	 * @param gname
	 *            圈子主ID 必填
	 * @param gname
	 *            圈子名称 必填
	 * @param introduction
	 *            圈子描述 可选
	 * @param categoryId
	 *            圈子分类ID (必填)
	 * @param friendIds
	 *            圈子成员ID串，逗号分割
	 * @return
	 * @throws ServicesException
	 */
	public Group createMyGroup(String ownerId, String gName,
			String introduction, String categoryId, String friendIds)
			throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"createMyGroup(gName:%1$s introduction:%2$s categoryId:%3$s friendIds:%4$s)",
						gName, introduction, categoryId, friendIds));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(ownerId))
				params.add(new StringParameter("ownerId", ownerId));
			if (!TextUtils.isEmpty(gName))
				params.add(new StringParameter("gName", gName));
			if (!TextUtils.isEmpty(introduction))
				params.add(new StringParameter("introduction", introduction));
			if (!TextUtils.isEmpty(categoryId))
				params.add(new StringParameter("categoryId", categoryId));
			if (!TextUtils.isEmpty(friendIds))
				params.add(new StringParameter("friendIds", friendIds));
			json = getJsonByPost(Constant.CREATE_QUANZI_SAVE, params);
			Logger.i("json", "createMyGroup()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					/*
					 * Group info = gson.fromJson(jsonObj.getString("obj"),
					 * Group.class);
					 */
					Group info = new Group();
					info.setId(jsonObj.getString("obj"));
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 修改圈子
	 * 
	 * @param id
	 *            =>(必填 圈子 id)
	 * @param gname
	 *            =>(选填 圈子名称)
	 * @param introduction
	 *            =>(选填 简介)
	 * @param isSecret
	 *            =>(选填 是否私密圈)
	 * @param isAudit
	 *            =>(选填 是否验证)
	 * @param friendIds
	 *            =>(选填 拉好友)
	 * @return
	 * @throws ServicesException
	 */
	public Group modifyMyGroup(String id, String gName, String introduction,
			String isSecret, String isAudit, String friendIds)
			throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"modifyMyGroup(id:%1$s gName:%2$s introduction:%3$s isSecret:%4$s isAudit:%5$s friendIds:%6$s)",
						id, gName, introduction, isSecret, isAudit, friendIds));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(id))
				params.add(new StringParameter("id", id));
			if (!TextUtils.isEmpty(gName))
				params.add(new StringParameter("gName", gName));
			if (!TextUtils.isEmpty(introduction))
				params.add(new StringParameter("introduction", introduction));
			if (!TextUtils.isEmpty(isSecret))
				params.add(new StringParameter("isSecret", isSecret));
			if (!TextUtils.isEmpty(isAudit))
				params.add(new StringParameter("isAudit", isAudit));
			if (!TextUtils.isEmpty(friendIds))
				params.add(new StringParameter("friendIds", friendIds));
			json = getJsonByPost(Constant.UPDATE_QUANZI_SAVE, params);
			Logger.i("json", "modifyMyGroup()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					/*
					 * Group info = gson.fromJson(jsonObj.getString("obj"),
					 * Group.class);
					 */
					Group info = new Group();
					info.setId(jsonObj.getString("obj"));
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取圈子成员
	 * 
	 * @param groupId
	 * @param page
	 * @param rows
	 * @return
	 * @throws ServicesException
	 */
	public GroupMembersInfoConfig queryMemberUserInfosByGroupId(String groupId,
			String page, String rows) throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"queryMemberUserInfosByGroupId(groupId:%1$s page:%2$s rows:%3$s)",
						groupId, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.QUARY_QUANZI_MEMBER, params);
			Logger.i("json", "queryMemberUserInfosByGroupId()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					GroupMembersInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							GroupMembersInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 圈子设置---获取圈子明细
	 * 
	 * @param id
	 *            圈子ID
	 * @return
	 * @throws ServicesException
	 */
	public GroupSetupInfoConfig queryGroupDetailById(String id)
			throws ServicesException {
		Logger.i("json", "queryGroupDetailById(id=" + id + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(id))
				params.add(new StringParameter("id", id));
			json = getJsonByPost(Constant.QUARY_QUANZI_DETAIL, params);
			Logger.i("json", "queryGroupDetailById()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					GroupSetupInfoConfig groupDetail = gson.fromJson(
							jsonObj.getString("obj"),
							GroupSetupInfoConfig.class);
					return groupDetail;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 圈子设置---解散圈子
	 * 
	 * @param id
	 *            圈子ID
	 * @return
	 * @throws ServicesException
	 */
	public boolean RemoveGroupById(String id) throws ServicesException {
		Logger.i("json", "RemoveGroupById(id=" + id + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(id))
				params.add(new StringParameter("id", id));
			json = getJsonByPost(Constant.REMOVE_GROUP, params);
			Logger.i("json", "RemoveGroupById()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/**
	 * 修改圈子图片
	 * 
	 * @param id
	 *            圈子ID
	 * @param file
	 *            图片路径
	 * @return
	 * @throws ServicesException
	 */
	public boolean sendGroupImg(String id, File img) throws ServicesException {
		Logger.i("json", "sendGroupImg(id=" + id + ",img =" + img.getName()
				+ ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(id))
				params.add(new StringParameter("id", id));
			if (img != null)
				params.add(new FileParameter("img", img));
			json = getJsonByPost(Constant.CHANGE_GROUP_IMG, params);
			Logger.i("json", "sendGroupImg()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/**
	 * 获取圈子主页头部明细
	 * 
	 * @param groupId
	 *            圈子ID
	 * @param userId
	 *            用户ID
	 * @return
	 * @throws ServicesException
	 */
	public GroupHomePageHeadInfoConfig queryGroupDetailByGroupUser(
			String groupId, String userId) throws ServicesException {
		Logger.i("json", "queryGroupDetailByGroupUser(groupId=" + groupId
				+ " userId=" + userId + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			json = getJsonByPost(Constant.QUARY_QUANZI_HOMEPAGE_DETAIL, params);
			Logger.i("json", "queryGroupDetailByGroupUser()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					GroupHomePageHeadInfoConfig groupDetail = gson.fromJson(
							jsonObj.getString("obj"),
							GroupHomePageHeadInfoConfig.class);
					groupDetail.setCode(result.getCode());
					return groupDetail;
				} else {
					// throw new ServicesException(result.getMsg());
					GroupHomePageHeadInfoConfig groupDetail = new GroupHomePageHeadInfoConfig();
					groupDetail.setCode(result.getCode());
					groupDetail.setMsg(result.getMsg());
					return groupDetail;
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 加入\取消加入圈子
	 * 
	 * @param groupId
	 *            (必填 圈子 ID)
	 * @param userId
	 *            (必填 当前用户 ID)
	 * @param isJoin
	 *            (必填 true加入 false取消加入)
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo2 joinGroup(String groupId, String userId, String isJoin)
			throws ServicesException {
		Logger.i("json", "sendGroupImg(groupId=" + groupId + ",userId ="
				+ userId + ",isJoin =" + isJoin + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(isJoin))
				params.add(new StringParameter("isJoin", isJoin));
			json = getJsonByPost(Constant.JION_OR_CANCEL_OR_DELETE_QUANZI,
					params);
			Logger.i("json", "joinGroup()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			throw new ServicesException("没获取到任何数据");
		}
	}

	/**
	 * 圈子管理 – 全部
	 * 
	 * @param userId
	 *            =>(必填 用户ID)
	 * @param page
	 *            =>1 当前页 (可不加 默认1)
	 * @param rows
	 *            =>每页显示记录数 (可不加 默认10)
	 * @return
	 * @throws ServicesException
	 */
	public MyQuanziListInfoConfig queryAllFocusGroupByUserId(String userId,
			String page, String rows) throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"queryAllFocusGroupByUserId(userId:%1$s page:%2$s rows:%3$s)",
				userId, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.QUARY_ALL_FOCUS_GROUP, params);
			Logger.i("json", "queryAllFocusGroupByUserId()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					MyQuanziListInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							MyQuanziListInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 圈子管理 – 我的
	 * 
	 * @param userId
	 *            =>(必填 用户ID)
	 * @param page
	 *            =>1 当前页 (可不加 默认1)
	 * @param rows
	 *            =>每页显示记录数 (可不加 默认10)
	 * @return
	 * @throws ServicesException
	 */
	public MyQuanziListInfoConfig queryMyGroupByUserId(String userId,
			String page, String rows) throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"queryMyGroupByUserId(userId:%1$s page:%2$s rows:%3$s)",
				userId, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.QUARY_MY_CREATE_GROUP, params);
			Logger.i("json", "queryMyGroupByUserId()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					MyQuanziListInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							MyQuanziListInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取用户专辑视频
	 * 
	 * @param userId
	 *            =>用户id，必选
	 * @param albumId
	 *            =>专辑id，必选
	 * @param page
	 *            =>页码
	 * @param rows
	 *            =>每页显示记录数 (可不加 默认10)
	 * @return//ft_12.31添加askUserId
	 * @throws ServicesException
	 */
	public UserAlbumVideoInfoConfig queryUserAlbumVideo(String userId,
			String albumId, String page, String rows) throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"queryMyGroupByUserId(userId:%1$s albumId:%2$s page:%3$s rows:%4$s)",
						userId, albumId, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(albumId))
				params.add(new StringParameter("albumId", albumId));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			if (LoginInfo.getInstance().isLogin()) {
				params.add(new StringParameter("askUserId", LoginInfo
						.getInstance().getUserId()));
			} else {
				params.add(new StringParameter("askUserId", ""));
			}
			json = getJsonByPost(Constant.QUARY_USER_ALBUM_VIDEO, params);
			Logger.i("json", "queryUserAlbumVideo()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					UserAlbumVideoInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							UserAlbumVideoInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 从专辑删除视频
	 * 
	 * @param albumId
	 *            （专辑ID）
	 * @param videoId
	 *            （视频ID）
	 * @return
	 * @throws ServicesException
	 */
	public boolean removeVideoFromAlbum(String albumId, String videoId)
			throws ServicesException {
		Logger.i("json", "removeVideoFromAlbum(albumId=" + albumId
				+ ",videoId =" + videoId + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(albumId))
				params.add(new StringParameter("albumId", albumId));
			if (!TextUtils.isEmpty(videoId))
				params.add(new StringParameter("videoId", videoId));
			json = getJsonByPost(Constant.REMOVE_VIDEO_FROM_ALBUM, params);
			Logger.i("json", "removeVideoFromAlbum()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/*
	 * groupId=1 (必填 圈子 ID) page = 1 当前页 (可不加 默认1) rows = 10 每页显示记录数 (可不加 默认10)
	 */
	public WaterFallDataInfoConfig queryGroupVideosByGroupId(String groupId,
			String page, String rows) throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"queryGroupVideosByGroupId(groupId:%1$s page:%2$s rows:%3$s)",
				groupId, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.QUERY_GROUP_VIDEOS_BY_GROUPID, params);
			Logger.i("json", "queryGroupVideosByGroupId()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					WaterFallDataInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							WaterFallDataInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 删除圈子视频
	 * 
	 * @param groupId
	 *            (必填 圈子ID)
	 * @param videoId
	 *            (必填 视频ID)
	 * @return
	 * @throws ServicesException
	 */
	public boolean removeGroupVideo(String groupId, String videoId)
			throws ServicesException {
		Logger.i("json", "removeGroupVideo(groupId=" + groupId + ",videoId ="
				+ videoId + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(videoId))
				params.add(new StringParameter("videoId", videoId));
			json = getJsonByPost(Constant.REMOVE_GROUP_VIDEO, params);
			Logger.i("json", "removeGroupVideo()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/**
	 * 圈子视频置顶
	 * 
	 * @param groupId
	 *            (必填 圈子ID)
	 * @param videoId
	 *            (必填 视频ID)
	 * @param isTop
	 *            (必填 是否置顶)
	 * @return
	 * @throws ServicesException
	 */
	public boolean videoTop(String groupId, String videoId, String isTop)
			throws ServicesException {
		Logger.i("json", "removeGroupVideo(groupId=" + groupId + ",videoId ="
				+ videoId + ",isTop =" + isTop + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(videoId))
				params.add(new StringParameter("videoId", videoId));
			if (!TextUtils.isEmpty(isTop))
				params.add(new StringParameter("isTop", isTop));
			json = getJsonByPost(Constant.GROUP_VIDEO_TOP, params);
			Logger.i("json", "removeGroupVideo()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/**
	 * 圈子置顶
	 * 
	 * @param groupId
	 *            (必填 圈子ID)
	 * @param userId
	 *            (必填 用户ID)
	 * @param isTop
	 *            (必填 是否置顶)
	 * @return
	 * @throws ServicesException
	 */
	public boolean userGroupTop(String groupId, String userId, String isTop)
			throws ServicesException {
		Logger.i("json", "userGroupTop(groupId=" + groupId + ",userId ="
				+ userId + ",isTop =" + isTop + ")");
		String json = null;
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(groupId))
				params.add(new StringParameter("groupId", groupId));
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(isTop))
				params.add(new StringParameter("isTop", isTop));
			json = getJsonByPost(Constant.USER_GROUP_TOP, params);
			Logger.i("json", "userGroupTop()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return true;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return false;
		}
	}

	/*
	 * 参数： userId=32029 （不能为空） friendGroupTime 可以为’’,空字符串,毫秒值，朋友圈的时间
	 * ownerGroupTime 可以为’’,空字符串,毫秒值，自建圈的时间 focusGroupTime 可以为’’,空字符串,毫秒值，关注圈的时间
	 */
	/**
	 * 
	 * @param userId
	 *            （不能为空）
	 * @param friendGroupTime
	 *            可以为’’,空字符串,毫秒值，朋友圈的时间
	 * @param ownerGroupTime
	 *            可以为’’,空字符串,毫秒值，自建圈的时间
	 * @param focusGroupTime
	 *            可以为’’,空字符串,毫秒值，关注圈的时间
	 * @return
	 * @throws ServicesException
	 */
	public GroupRedPointInfoConfig queryRedPoint(String userId,
			String friendGroupTime, String ownerGroupTime, String focusGroupTime)
			throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"queryRedPoint(userId:%1$s friendGroupTime:%2$s ownerGroupTime:%3$s focusGroupTime:%4$s)",
						userId, friendGroupTime, ownerGroupTime, focusGroupTime));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(userId))
				params.add(new StringParameter("userId", userId));
			if (!TextUtils.isEmpty(friendGroupTime))
				params.add(new StringParameter("friendGroupTime",
						friendGroupTime));
			if (!TextUtils.isEmpty(ownerGroupTime))
				params.add(new StringParameter("ownerGroupTime", ownerGroupTime));
			if (!TextUtils.isEmpty(focusGroupTime))
				params.add(new StringParameter("focusGroupTime", focusGroupTime));
			json = getJsonByPost(Constant.CHECK_RED_POINT, params);
			Logger.i("json", "queryRedPoint()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					GroupRedPointInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							GroupRedPointInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 活动详情
	 * 
	 * @param activityId
	 * @return
	 * @throws ServicesException
	 */
	public ActionInfoConfig getActionActivity(String activityId)
			throws ServicesException {
		String json = null;
		Logger.i("json",
				String.format("getActivity(activityId=" + activityId + ")"));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(activityId))
				params.add(new StringParameter("activityId", activityId));
			json = getJsonByPost(Constant.GET_ACTION_ACTIVITY, params);
			Logger.i("json", "getActionActivity()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					JSONObject activity = new JSONObject(
							jsonObj.getString("obj"));
					ActionInfoConfig info = gson.fromJson(
							activity.getString("activity"),
							ActionInfoConfig.class);
					Logger.i("sdfds", jsonObj.getString("obj"));
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/*
	 * 参数 : activityId=17 （必填）活动id isWin=1 （可选）加上这个参数值设为1就是取获奖视频
	 */
	/**
	 * 
	 * @param activityId
	 *            （必填）活动id
	 * @param isWin
	 * @return
	 * @throws ServicesException
	 */
	public WaterFallDataInfoConfig queryActivityVideoList(String activityId,
			String isWin, String page, String rows) throws ServicesException {
		String json = null;
		Logger.i(
				"json",
				String.format(
						"queryHotVideos(activityId:%1$s isWin:%2$s page:%3$s rows:%4$s)",
						activityId, isWin, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(activityId))
				params.add(new StringParameter("activityId", activityId));
			if (!TextUtils.isEmpty(isWin))
				params.add(new StringParameter("isWin", isWin));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.ACTION_VIDEO_LIST, params);
			Logger.i("json", "queryActivityVideoList()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					JSONObject jsonObj = new JSONObject(json);
					WaterFallDataInfoConfig info = gson.fromJson(
							jsonObj.getString("obj"),
							WaterFallDataInfoConfig.class);
					return info;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取首页视频分类
	 * 
	 * @param categoryId
	 * @param page
	 * @param rows
	 * @return
	 * @throws ServicesException
	 */
	public ClassificationInfoConfig queryVideoClassification(String categoryId,
			String page, String rows, int mFlag) throws ServicesException {
		String json = null;

		try {
			ParameterList params = new ParameterList();
			switch (mFlag) {
			// case Constant.CLASSIFICATION_HOME_FLAG:
			// Logger.i(
			// "json",
			// String.format(
			// "queryHotVideos(homeCategoryId:%1$s page:%2$s rows:%3$s)",
			// categoryId, page, rows));
			// if (!TextUtils.isEmpty(categoryId))
			// params.add(new StringParameter("homeCategoryId", categoryId));
			// if (!TextUtils.isEmpty(page))
			// params.add(new StringParameter("page", page));
			// if (!TextUtils.isEmpty(rows))
			// params.add(new StringParameter("rows", rows));
			// json = getJsonByPost(Constant.ACTION_HOMEVIDEO_CLASSIFICATION,
			// params);
			// break;
			case Constant.CLASSIFICATION_HOME_FLAG:
			case Constant.CLASSIFICATION_DISCOVERY_FLAG:
				Logger.i(
						"json",
						String.format(
								"queryHotVideos(videoCategoryId:%1$s page:%2$s rows:%3$s)",
								categoryId, page, rows));
				if ("1".equals(page)) {
					json = getJsonByGet(
							Constant.ACTION_DISCOVERYVIDEO_CLASSIFICATION_STATIC
									+ categoryId + ".json", null);
				} else {
					if (!TextUtils.isEmpty(categoryId))
						params.add(new StringParameter("videoCategoryId",
								categoryId));
					if (!TextUtils.isEmpty(page))
						params.add(new StringParameter("page", page));
					if (!TextUtils.isEmpty(rows))
						params.add(new StringParameter("rows", rows));
					json = getJsonByPost(
							Constant.ACTION_DISCOVERYVIDEO_CLASSIFICATION,
							params);
				}
				break;
			default:
				break;
			}

			Logger.i("json", "queryVideoClassification()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ClassificationInfoConfig result = gson.fromJson(json,
						ClassificationInfoConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}

	}

	/**
	 * 上传文件到服务器
	 * 
	 * @param file
	 *            文件
	 * @return
	 */
	public String updateFileToServer(File file) throws ServicesException {
		try {
			if (!file.exists()) {
				return null;
			}
			URL url = new URL(Constant.ACTION_UPDATA_IMAGE + "?userId="
					+ LoginInfo.getInstance().getUserId());
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			con.setDoInput(true);
			con.setDoOutput(true);
			con.setUseCaches(false);
			/* 设置传送的method=POST */
			con.setRequestMethod("POST");
			/* setRequestProperty */
			con.setRequestProperty("Connection", "Keep-Alive");
			con.setRequestProperty("Charset", "UTF-8");
			con.setRequestProperty("Content-Type", "application/octet-stream");
			/* 设置DataOutputStream */
			DataOutputStream ds = new DataOutputStream(con.getOutputStream());
			FileInputStream fStream = new FileInputStream(file);
			/* 设置每次写入1024bytes */
			int bufferSize = 1024;
			byte[] buffer = new byte[bufferSize];
			int length = -1;
			/* 从文件读取数据至缓冲区 */
			while ((length = fStream.read(buffer)) != -1) {
				/* 将资料写入DataOutputStream中 */
				ds.write(buffer, 0, length);
			}
			fStream.close();
			ds.flush();
			/* 取得Response内容 */
			InputStream is = con.getInputStream();
			int ch;
			StringBuffer b = new StringBuffer();
			while ((ch = is.read()) != -1) {
				b.append((char) ch);
			}
			/* 关闭DataOutputStream */
			ds.close();
			String jsonStr = b.toString();
			if (!TextUtils.isEmpty(jsonStr)) {
				JSONObject jsonObj = new JSONObject(jsonStr);
				JSONObject result = jsonObj.getJSONObject("result");
				if (result.getString("code").equals("0")) {
					return jsonObj.getString("backgroundImg");
				}
			}
			return null;
		} catch (ConnectException e) {
			throw new ServicesException("网络请求异常，请检查网络");
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			throw new ServicesException("URL协议、格式或者路径错误");
		} catch (ProtocolException e) {
			// TODO Auto-generated catch block
			throw new ServicesException("连接服务器请求错误");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			throw new ServicesException("文件的路径不正确");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			throw new ServicesException("网络请求异常，请检查网络");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			throw new ServicesException("json数据转换异常");
		}
	}

	/**
	 * 获取发现页信息
	 * 
	 * @return
	 * @throws ServicesException
	 */
	public VideoCategorieConfig getVideoCategorieInfo()
			throws ServicesException {
		String json = null;
		Logger.i("json", "find");
		try {
			json = getJsonByGet(Constant.VIDEO_CATEGORIE_DATA, null);
			Logger.i("json", "findAllSimpleVideoCategories()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				VideoCategorieConfig info = gson.fromJson(json,
						VideoCategorieConfig.class);
				if (info.isSuccess()) {
					return info;
				} else {
					throw new ServicesException(info.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取播放次数
	 * 
	 * @param videoId
	 *            视频ID
	 * @return
	 * @throws ServicesException
	 */
	public ResultInfo2 getVideoPlayCount(String videoId)
			throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"increaseVideoDetailPlayNumByVideoId(videoId:%1$s)", videoId));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(videoId))
				params.add(new StringParameter("videoId", videoId));
			json = getJsonByPost(Constant.VIDEO_PLAY_COUNT, params);
			Logger.i("json", "increaseVideoDetailPlayNumByVideoId()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				ResultInfo2 result = gson.fromJson(json, ResultInfo2.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取话题头部信息
	 * 
	 * @param actionId
	 * @return
	 * @throws ServicesException
	 */
	public TopicTitleInfoConfig getTopicTitleInfo(String actionId)
			throws ServicesException {
		String json = null;
		Logger.i("json", String.format("getTopic(id=" + actionId + ")"));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(actionId))
				params.add(new StringParameter("id", actionId));
			json = getJsonByPost(Constant.TOPIC_TITLE, params);
			Logger.i("json", "getTopicTitleInfo()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				TopicTitleInfoConfig result = gson.fromJson(json,
						TopicTitleInfoConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取话题头部信息
	 * 
	 * @param actionName
	 * @return
	 * @throws ServicesException
	 */
	public TopicTitleInfoConfig getTopicTitleInfoByName(String actionName)
			throws ServicesException {
		String json = null;
		Logger.i("json",
				String.format("getTopicByName(name=" + actionName + ")"));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(actionName))
				params.add(new StringParameter("name", actionName));
			json = getJsonByPost(Constant.TOPIC_TITLEBYNAME, params);
			Logger.i("json", "getTopicTitleInfoByName()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				TopicTitleInfoConfig result = gson.fromJson(json,
						TopicTitleInfoConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 
	 * @param topicId
	 *            （必填）话题id
	 * @param topicName
	 * @param type
	 * @param page
	 * @param rows
	 * @return
	 * @throws ServicesException
	 */
	public TopicListInfoConfig queryTopicVideoList(String topicId,
			String topicName, String type, String page, String rows)
			throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"getTopicVideos(topicId:%1$s type:%2$s page:%3$s rows:%4$s)",
				topicId, type, page, rows));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(topicId)) {
				params.add(new StringParameter("topicId", topicId));
			} else {
				if (!TextUtils.isEmpty(topicName)) {
					params.add(new StringParameter("topicName", topicName));
				}
			}
			if (!TextUtils.isEmpty(type))
				params.add(new StringParameter("type", type));
			if (!TextUtils.isEmpty(page))
				params.add(new StringParameter("page", page));
			if (!TextUtils.isEmpty(rows))
				params.add(new StringParameter("rows", rows));
			json = getJsonByPost(Constant.TOPIC_VIDEO_LIST, params);
			Logger.i("json", "queryTopicVideoList()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				TopicListInfoConfig result = gson.fromJson(json,
						TopicListInfoConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 
	 * @param mobile
	 * @param mobilecode
	 *            392768
	 * @param pwd
	 * @return
	 * @throws ServicesException
	 */
	public BaseInfo userRegister(String mobile, String mobilecode, String pwd)
			throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"quickreg(mobile:%1$s mobilecode:%2$s pwd:%3$s)", mobile,
				mobilecode, pwd));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(mobile)) {
				params.add(new StringParameter("mobile", mobile));
			}
			if (!TextUtils.isEmpty(mobile)) {
				params.add(new StringParameter("mobilecode", mobilecode));
			}
			if (!TextUtils.isEmpty(mobile)) {
				params.add(new StringParameter("pwd", pwd));
			}
			json = getJsonByPost(Constant.ACTION_USER_REGISTER, params);
			Logger.i("json", "userRegister()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				BaseInfo baseInfo = new BaseInfo();
				JSONObject jsonObj = new JSONObject(json);
				JSONObject result = jsonObj.getJSONObject("result");
				baseInfo.setCode(result.getString("code"));
				baseInfo.setMsg(result.getString("message"));
				return baseInfo;
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 生成订单
	 * 
	 * @param userId
	 * @param videoId
	 * @param money
	 * @param payWay
	 * @return
	 * @throws ServicesException
	 */
	public PayOrderConfig getPayOrder(String userId, String videoId,
			String money, String payWay) throws ServicesException {
		String json = null;
		Logger.i("json", String.format(
				"createorder(userId:%1$s videoId:%2$s money:%3$s payWay:%4$s)",
				userId, videoId, money, payWay));
		try {
			ParameterList params = new ParameterList();
			if (!TextUtils.isEmpty(userId)) {
				params.add(new StringParameter("userId", userId));
			}
			if (!TextUtils.isEmpty(videoId)) {
				params.add(new StringParameter("videoId", videoId));
			}
			if (!TextUtils.isEmpty(money)) {
				params.add(new StringParameter("amount", money));
			}
			if (!TextUtils.isEmpty(payWay)) {
				params.add(new StringParameter("payWay", payWay));
			}
			json = getJsonByGet(Constant.ACTION_PAY_ORDER, params);
			Logger.i("json", "getAlipayOrder()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				PayOrderConfig result = gson.fromJson(json,
						PayOrderConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取支付成功视频列表
	 * 
	 * @throws ServicesException
	 */
	public RewardVideoConfig getPaySuccessVideoList() throws ServicesException {
		String json = null;
		try {
			json = getJsonByGet(Constant.ACTION_PAY_SUCCESS_VIDEOLIST, null);
			Logger.i("json", "getPaySuccessVideoList()\n" + json);
		} catch (NetException e) {
			throw new ServicesException(e.getMessage());
		}
		if (!TextUtils.isEmpty(json)) {
			try {
				Gson gson = new Gson();
				RewardVideoConfig result = gson.fromJson(json,
						RewardVideoConfig.class);
				if (result.isSuccess()) {
					return result;
				} else {
					throw new ServicesException(result.getMsg());
				}
			} catch (Exception ex) {
				throw new ServicesException(Constant.NETWORK_MESSAGE_HINT);
			}
		} else {
			return null;
		}
	}

	/**
	 * 获取Tick
	 * 
	 * @param context
	 * @param uid
	 * @param onResponseListener
	 */
	public void getTick(Context context, String uid,
			OnResponseListener onResponseListener) {
		String url = String.format(Constant.PETITION_TICK, uid,
				Constant.PRODUCT_CODE, Constant.PRODUCT_VERSION,
				Constant.DEVICEID);
		Logger.i(TAG, "getTick()-->" + url);
		RequestManager.getInstance().getRequest(context, url, TickEntity.class,
				onResponseListener);
	}

	/**
	 * 获取支付订单
	 * 
	 * @param context
	 * @param uid
	 * @param commodityid
	 * @param payWay
	 * @param onResponseListener
	 */
	public void getPayOrder(Context context, String uid, String commodityid,
			String payWay, OnResponseListener onResponseListener) {
		String url = String.format(Constant.LIVEPAY_ORDER, commodityid, payWay,
				uid, Constant.PRODUCT_CODE, Constant.PRODUCT_VERSION,
				Constant.DEVICEID, Constant.getPayKey(uid, commodityid));
		Logger.i(TAG, "支付订单url==" + url);
		RequestManager.getInstance().getRequest(context, url,
				PayOrderEntity.class, onResponseListener);
	}
	
	/**
	 * 检查Tick
	 * 
	 * @param context
	 * @param uid
	 * @param tick
	 * @param onResponseListener
	 */
	public void getCheckTick(Context context, String uid, String tick,
			OnResponseListener onResponseListener) {
		String url = String.format(Constant.PETITION_CHECKTICK, uid,
				Constant.PRODUCT_CODE, Constant.PRODUCT_VERSION,
				Constant.DEVICEID);
		ParamList params = new ParamList();
		params.add(new Parameter("tick", tick));
		Logger.i(TAG, "getCheckTick()-->" + url);
		RequestManager.getInstance().postRequest(context, url, params,
				TickEntity.class, onResponseListener);
	}
	
	
	/**
	 * 开机上报接口
	 * @param context
	 */
	public void startingUpToServer(Context context) {
		String url = "http://dc.v1.cn/start.html";
		String timestamp = System.currentTimeMillis() + "";
		HashMap<String, String> signMap = new HashMap<String, String>();
		signMap.put("devid", Constant.DEVICEID);
		signMap.put("devtype", "2"); // android
		signMap.put("pcode", Constant.PRODUCT_CODE);
		signMap.put("t", timestamp); // 时间戳
		signMap.put("uid", "0");
		signMap.put("v", Constant.PRODUCT_VERSION);
		signMap.put("ver", "1.0");
		signMap.put("adid", "10");
		signMap.put("cid", "-1");
		url = url + ParamSignUtil.splitJointParam(signMap);
		Logger.i(TAG, "startingUpToServer：url=" + url);
		RequestManager.getInstance().getRequest(context, url);
	}
	
	/**
	 * 广告上报接口
	 * @param context
	 * @param thirdid  第三方广告id
	 * @param uid 非登录 填写0 登录填写userid
	 * @param adid 广告位置id 参考广告位定义
	 * @param cz 1. 广告曝光 2. 广告点击
	 */
	public void AdUpToServer(Context context,String thirdid,String uid,String adid,String cz,String cid) {
		String url = "http://dc.v1.cn/ad.html";
		String timestamp = System.currentTimeMillis() + "";
		HashMap<String, String> signMap = new HashMap<String, String>();
		signMap.put("devid", Constant.DEVICEID);
		signMap.put("pcode", Constant.PRODUCT_CODE);
		signMap.put("v", Constant.PRODUCT_VERSION);
		signMap.put("ver", "1.0");
		signMap.put("devtype", "2"); // android
		signMap.put("t", timestamp); // 时间戳
		signMap.put("thirdid", thirdid);
		if (TextUtils.isEmpty(uid)) {
			signMap.put("uid", "0");
		} else {
			signMap.put("uid", uid);
		}
		signMap.put("adid", adid);
		signMap.put("cz", cz);
		signMap.put("cid", cid);
		url = url + ParamSignUtil.splitJointParam(signMap);
		Logger.i(TAG, "AdUpToServer：url=" + url);
		RequestManager.getInstance().getRequest(context, url);
	}
	
	/**
	 * 视频播放上报接口
	 * @param context
	 * @param uuid  
	 * @param uid 非登录 填写0 登录填写userid
	 * @param vid 
	 * @param source 来源：1.焦点图 2.首页推荐位 3.频道列表 4.播放页横栏 5.主题 6.推送 7.其它
	 * @param f 播放状态标记 0 开始播放 1. 播放中 2. 播放结束
	 */
	public void videoPlayUpToServer(Context context,String uuid,String uid,String vid,String source,String f,String time) {
		String url = "http://dc.v1.cn/videoplay.html";
		String timestamp = System.currentTimeMillis() + "";
		HashMap<String, String> signMap = new HashMap<String, String>();
		signMap.put("devid", Constant.DEVICEID);
		signMap.put("pcode", Constant.PRODUCT_CODE);
		signMap.put("v", Constant.PRODUCT_VERSION);
		signMap.put("ver", "1.0");
		signMap.put("devtype", "2"); // android
		signMap.put("t", timestamp); // 时间戳
		signMap.put("uuid", uuid);
		if (TextUtils.isEmpty(uid)) {
			signMap.put("uid", "0");
		} else {
			signMap.put("uid", uid);
		}
		signMap.put("source", source);
		signMap.put("vid", vid);
		signMap.put("f", f);
		signMap.put("time", time);
		url = url + ParamSignUtil.splitJointParam(signMap);
		Logger.i(TAG, "videoPlayUpToServer：url=" + url);
		RequestManager.getInstance().getRequest(context, url);
	}
	
	
	 /**
     * 点播视频文件信息
     * @param context
     * @param vid
     * @param onResponseListener
     */
    public void getVideoFile(Context context, String vid, RequestManager.OnResponseListener onResponseListener) {
        String timeStamp = System.currentTimeMillis() / 1000 + "";
		String uid = "0";
		String key = Constant.getVideoFileEncryptKey(uid, vid, timeStamp);
		String url = String.format(V1VideoHttpApi.VR_VIDEOFILE(), uid, vid, "0",
				timeStamp, key, Constant.DEVICEID);
		Logger.i(TAG, "点播视频文件url=" + url);
        RequestManager.getInstance().getRequest(context, url, VideoFileEntity.class, onResponseListener);
    }
    
    /**
     * 获取评论
     *
     * @param context
     * @param vid
     * @param last_id
     * @param object_type       1. 视频 2. 圈子
     * @param sort
     * @param onResponseListener
     */
	public void getCommentData(Context context, String vid, String last_id,
			String object_type, String sort,
			RequestManager.OnResponseListener onResponseListener) {
		String url = String.format(Constant.COMMENT_LIST, object_type, vid,
				last_id, sort, Constant.DEVICEID);
		Logger.i(TAG, "获取评论url=" + url);
		RequestManager.getInstance().getRequest(context, url,
				CommentEntity.class, onResponseListener);
	}
	
	/**
	 * 获取焦点图
	 * @param context
	 * @param cid
	 * @param ctype
	 * @param onResponseListener
	 */
	public void getCarouselData(Context context, String cid, String ctype,
			RequestManager.OnResponseListener onResponseListener) {
		String url = String.format(V1VideoHttpApi.CAROUSEL_LIST(), cid, ctype,
				Constant.DEVICEID);
		Logger.i(TAG, "获取焦点图url=" + url);
		RequestManager.getInstance().getRequest(context, url,
				CarouselEntity.class, onResponseListener);
	}

}
